gulios/sxf-config
Composer 安装命令:
composer require gulios/sxf-config
包简介
SXF Config Component
README 文档
README
The Config component based on Illuminate and DotEnv packages. (Laravel idea)
Features
- store authorization values in .env
- use cached configuration
- default values for ENV
- nested configuration structure
Example usage:
-
Use Composer to install SXF Config into your project:
composer require gulios/sxf-config
-
Initialize in your code:
$basePath = realpath(__DIR__ . '/../') . DIRECTORY_SEPARATOR; $configuration = new Config(); $configuration->setConfigFilesPath($basePath . 'config/'); $configuration->setEnvFile($basePath . '.env'); $configuration->setCacheConfigFile($basePath . 'cache/configuration.php');
You can get configuration by:
$configuration->getAll();
or
$configuration->get('app.debug')
etc
Configuration data
Package scan all .php files in defined path (setConfigFilesPath()).
Example file 'config/app.php'
return [ 'first_test' => env('TEST', 'defaultvalue'), 'second_test' => [ 'key' => 'value' ] ];
As you see if you don't set TEST value in .env file it will get 'defaultvalue'.
Config directory structure can be nested.
Cache
You can execute just:
$configuration->clearCache(); or $configuration->createCache();
or if you use Symfony console you can use two commands:
$config = new Config(); $config->setConfigFilesPath($basePath . 'config/'); $config->setEnvFile($basePath . '.env'); $config->setCacheConfigFile($basePath . 'cache/configuration.php'); $app = new Application(); $app->add( new ConfigCacheCommand( $config->getConfigFilesPath(), $config->getEnvFile(), $config->getCacheConfigFile() ) ); $app->add( new ConfigCacheClearCommand( $config->getConfigFilesPath(), $config->getEnvFile(), $config->getCacheConfigFile() ) ); $app->run();
and run:
php bin/console config: Command "config:" is ambiguous. Did you mean one of these? config:create Create a cache file for faster configuration loading config:clear Remove the configuration cache file
it will create cache file with all your configuration.
统计信息
- 总下载量: 12
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-09-06