承接 getsky/phalcon-config-loader 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

getsky/phalcon-config-loader

Composer 安装命令:

composer require getsky/phalcon-config-loader

包简介

Component to load configuration from various files

README 文档

README

ConfigLoader - it's manager configuration files for Phalcon. It allows you to create a configuration of various formats (ini, yaml, JSON, PHP arrays or any other, for which you will add adapter) via a single method.

$configYml = $configLoader->create('config.yml');
$configIni = $configLoader->create('config.ini');
$configPhp = $configLoader->create('config.php');


// or use string
$string = 'foo = bar'
$configFromText = $configLoader->fromText($string, 'ini');

// or use arrays
$config = ['foo' => 'bar'];
$configFromArray = $configLoader->fromArray($config);

ConfigLoader is able to track %environment% in configuration files and replace it on our environment.

// Create ConfigLoader and specify the environment of our application
$configLoader = new ConfigLoader('prod');

// config.yml : test: %environment%
$configYml = $configLoader->create('config.yml');

echo $configYml->test;
// print: prod 

To add your adapter, you must call add () with transfer expansion and adapter class, which must inherit a class Phalcon\Config:

$config = $configLoader->add('xml', 'MyNamespace/XmlConfig');

Moreover, you can merge configuration files:

#config.ini
[test]
test = true
%res% = import.ini
exp = %res:import.ini
%class% = Test/Class::SERVICES
import-class =  %class:Test/Class::SERVICES
#import.ini
import = "test"
namespace Test;

class Class {
  const SERVICES = '/const.ini';
}
#const.ini
class = "class"

The result loading configuration from config.ini:

[                               
    'test' => [                 
        'test' => true,                             
        'import' => true,       
        'env' => 'dev',
        'exp' => [
            'import' => true,
            'env' => 'dev'
        ],
        'class' => "class",
        'impot-class' => [
            'class' => "class"
        ]
    ]                           
]                               

Declared variables in the parent file will not be replaced by variables from the child (only %res% or %class%):

# /app/config/config.ini
%res% = include.ini
[foo]
test = config-test
# /app/config/include.ini
[foo]
test = test
bar = bar
# result
[foo]
test = config-test
bar = bar

If you do not want to import resources (loading of the other configuration files in this configuration), the second parameter must pass a boolean false :

$config = $configLoader->create('config.ini', false);

统计信息

  • 总下载量: 449
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 0
  • 依赖项目数: 2
  • 推荐数: 0

GitHub 信息

  • Stars: 3
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2014-01-27

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固