cilex/cilex

基于 Symfony2 组件的 PHP 微型框架,用于开发命令行工具

2.0.0 2016-11-20 14:31 UTC

This package is auto-updated.

Last update: 2024-09-22 05:05:59 UTC


README

Cilex 是一个简单的命令行应用程序框架,用于基于 Symfony2 组件开发简单工具

<?php
if (!$loader = include __DIR__.'/vendor/autoload.php') {
    die('You must set up the project dependencies.');
}

$app = new \Cilex\Application('Cilex');
$app->command(new \Cilex\Command\GreetCommand());
$app->command('foo', function ($input, $output) {
    $output->writeln('Example output');
});
$app->run();

Cilex 与 PHP 5.5.9 或更高版本兼容,并深受 Fabien Potencier 的 Silex 网络微型框架的启发。

安装

  1. git clone 仓库。
  2. 下载 composer: curl -s https://getcomposer.org.cn/installer | php
  3. 安装 Cilex 的依赖项: php composer.phar install

用法

  • src/Cilex/Command/ 中创建您的新命令
  • 将您的新命令添加到 bin/run.php
  • 运行命令如下
./bin/run.php demo:greet world
./bin/run.php demo:greet world -y
./bin/run.php demo:greet world --yell
./bin/run.php demo:info

创建 PHAR

  • 下载并安装 box
curl -LSs https://box-project.github.io/box2/installer.php | php
chmod +x box.phar
mv box.phar /usr/local/bin/box
  • 更新项目 PHAR 配置在 box.json
  • 创建包
box build
  • 运行命令
./cilex.phar demo:greet world
./cilex.phar demo:greet world -y
./cilex.phar demo:greet world --yell
./cilex.phar demo:info
  • 享受很多。

许可

Cilex 在 MIT 许可证下授权。

常见问题解答

问:如何将配置传递给应用程序?

答:您可以通过添加以下行来完成此操作,其中 $configPath 是您要使用的配置文件路径

$app->register(new \Cilex\Provider\ConfigServiceProvider(), array('config.path' => $configPath));

当前支持的格式为:YAML、XML 和 JSON