kzykhys / console-service-provider
为 Silex 应用程序提供 Symfony/Console
dev-master
2013-05-29 03:10 UTC
Requires
- silex/silex: 1.0.*@dev
- symfony/console: >=2.3,<2.4-dev
This package is not auto-updated.
Last update: 2024-09-23 13:31:34 UTC
README
参数
-
console.options (可选): 选项数组
以下选项可用
- name: 应用程序名称 (Symfony\Component\Console\Application::setName())
- version: 应用程序版本 (Symfony\Component\Console\Application::setVersion())
-
console.commands (可选): 命令数组 (Symfony/Console/Command 实例)
服务
- console:
Symfony\Component\Console\Application
实例
用法
app/bootstrap.php
<?php use KzykHys\Silex\Provider\Console\ConsoleServiceProvider; $app = new \Silex\Appliation(); return $app;
app/console.php
<?php use KzykHys\Silex\Provider\Console\ConsoleServiceProvider; $app = require __DIR__ . '/bootstrap.php'; $app->register(new ConsoleServiceProvider()); $app['console.commands'] = $app->share($app->extend('console.commands', function (array $commands) { $commands[] = new YourCommand(); return $commands; })); $app->boot(); $app['console']->run();
$ php app/console.php
在您的命令中访问 "$app"
<?php use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; class YourCommand extends Command { protected function execute(InputInterface $input, OutputInterface $output) { /* @var \Silex\Application $app */ $app = $this->getHelper('silex')->getApplication(); } }
另请参阅
-
KzykHys/DoctrineORMServiceProvider 为 Silex 应用程序提供 DoctrineORM (以及 Doctrine 命令)
-
KzykHys/SilexDistribution 配置好的 Silex 集成
许可证
MIT 许可证