luismulinari / consoleful
一个用于操作 Symfony Console 组件和 Symfony 依赖注入组件的简单库
0.1.2
2016-01-27 03:13 UTC
Requires
- php: >=5.5
- lcobucci/di-builder: ~2.0
- symfony/config: 2.5.*
- symfony/console: 2.5.*
- symfony/dependency-injection: 2.5.*
- symfony/expression-language: 2.5.*
Requires (Dev)
This package is not auto-updated.
Last update: 2024-09-14 18:58:25 UTC
README
一个用于操作 Symfony Console 组件和 Symfony 依赖注入组件的简单库
安装
使用 composer 将 consoleful 添加到您的应用程序
"luismulinari/consoleful": "*"
使用示例
application.php - 入口点
<?php use Lcobucci\DependencyInjection\ContainerConfig; use LuisMulinari\Consoleful\Application; $autoloader = require __DIR__ . '/vendor/autoload.php'; $application = new Application( 'Application name', 'Version', new ContainerConfig(__DIR__ . 'services.xml') // services.[xml|yml|php] ); $application->add(new ExampleCommand()); $application->run();
ExampleCommand.php - 命令文件
<?php namespace Vendor\ExampleApp\Command; use LuisMulinari\Consoleful\Command\ContainerAwareCommand; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Command\Command; use Symfony\Component\DependencyInjection\ContainerAwareInterface; class ExampleCommand extends ContainerAwareCommand { protected function configure() { $this->setName("example"); $this->setDescription('Description example'); } protected function execute(InputInterface $input, OutputInterface $output) { $container = $this->getContainer(); $container->get('service.example'); $container->getParameter('parameter.example'); } }
您可以在这里看到其他示例