nuvoleweb/robo-config
Composer 安装命令:
composer require nuvoleweb/robo-config
包简介
CI/developer-friendly configuration processor for Robo.
README 文档
README
Robo Config enables a flexible configuration processing for Robo by providing the following features:
- Define your default configuration in
robo.yml.distand let developers override that locally in theirrobo.yml. - Allow configuration files to use properties defined within the same configuration in a Phing-like fashion.
- Allow all properties to be overridden on the command line so that they can be tweaked when running continuous integration builds.
- Access any configuration parameter via
$this->config('my.configuration.property);`
Installation
Install with Composer by running:
$ composer require nuvoleweb/robo-config
Usage
After installation add the following trait to your RoboFile.php:
<?php class RoboFile extends Robo\Tasks { use NuvoleWeb\Robo\Task\Config\loadTasks; }
For example, consider having the following robo.yml.dist file:
site: name: "Default site name" email: "me@example.com" url: "http://localhost" account: name: "admin" password: !account.name email: !site.email
And the following robo.yml file:
site: name: "My site name"
When running:
./vendor/bin/robo my-command -o "site.url: http://127.0.0.1:8888"
The resulting configuration will be:
site: name: "My site name" email: "me@example.com" url: "http://127.0.0.1:8888" account: name: "admin" password: "admin" email: "me@example.com"
Robo configuration in PHP files
Robo Config exposes three tasks that allow to convert a YAML configuration subset into PHP array. Such array will be then appended, prepended or written down to a PHP destination file as an array.
This might be useful for applications that have part of their configuration expressed in a PHP file, like Drupal or Silex.
For example, the following YAML portion:
settings: config: system.logging: error_level: verbose settings: scan_tests: TRUE
Will be converted into:
// Start settings processor block. $config["system.logging"] = array('error_level' => 'verbose'); $settings["scan_tests"] = true; // End settings processor block.
And added to a PHP file.
Append task
Given an existing /my/config.php file, by calling:
<?php class RoboFile { public function appendTask() { $this->taskAppendConfiguration('/my/config.php')->run(); } }
We will get the following result:
<?php // Content of /my/config.php here... // Start settings processor block. $config["system.logging"] = array('error_level' => 'verbose'); $settings["scan_tests"] = true; // End settings processor block.
Prepend task
Given an existing /my/config.php file, by calling:
<?php class RoboFile { public function appendTask() { $this->taskPrependConfiguration('/my/config.php')->run(); } }
We will get the following result:
<?php // Start settings processor block. $config["system.logging"] = array('error_level' => 'verbose'); $settings["scan_tests"] = true; // End settings processor block. // Content of /my/config.php here...
Write task
Given a non-existing /my/config.php file, by calling:
<?php class RoboFile { public function appendTask() { $this->taskWriteConfiguration('/my/config.php')->run(); } }
We will get the following result:
<?php // Start settings processor block. $config["system.logging"] = array('error_level' => 'verbose'); $settings["scan_tests"] = true; // End settings processor block.
Configure tasks
The behaviors of all tasks above can be customized as follow:
<?php class RoboFile { public function myTask() { $config = $this->getMyConfiguration(); $this->taskAppendConfiguration('/my/config.php', $config) // Use custom configuration. ->setBlockStart('// Start') // Change opening comment. ->setBlockEnd('// End') // Change closing comment. ->setConfigKey('parameters') // Use `parameters:` instead of default `settings:` ->run(); } }
Standalone usage
If you just want to use the PHP configuration file processing tasks above in your custom Robo application you can load them by including the following trait:
<?php class RoboFile { use \NuvoleWeb\Robo\Task\Config\Php\loadTasks; }
nuvoleweb/robo-config 适用场景与选型建议
nuvoleweb/robo-config 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 245.65k 次下载、GitHub Stars 达 5, 最近一次更新时间为 2017 年 05 月 02 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 nuvoleweb/robo-config 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 nuvoleweb/robo-config 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 245.65k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 5
- 点击次数: 23
- 依赖项目数: 58
- 推荐数: 0
其他信息
- 授权协议: GPL-2.0-or-later
- 更新时间: 2017-05-02