定制 gulios/sxf-config 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

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:
  1. Use Composer to install SXF Config into your project:

    composer require gulios/sxf-config
  2. 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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-09-06

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固