2017 © Pedro PelĂĄez
 

library symfony-console-di

Use symfony console with DI

image

fezfez/symfony-console-di

Use symfony console with DI

  • Wednesday, December 21, 2016
  • by fezfez
  • Repository
  • 3 Watchers
  • 3 Stars
  • 3,803 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

symfony-console-di

Build Status Code Coverage Scrutinizer Code Quality, (*1)

Symfony console with dependency injection capability and lazy loading, (*2)

Sample


use Fezfez\SymfonyDiConsole\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; class ACommand implements Command { private string $dependency; public function __construct(string $dependency) { $this->dependency = $dependency; } public function execute(InputInterface $input, OutputInterface $output): int { $output->write($this->dependency . 'hola' . $input->getArgument('hi') . $input->getOption('anoption')); return 1; } }

use Fezfez\SymfonyDiConsole\Command; use Fezfez\SymfonyDiConsole\CommandDefinition; use Fezfez\SymfonyDiConsole\CommandFactory; use Psr\Container\ContainerInterface; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputOption; class TestCommandFactory implements CommandFactory { public function createCommand(ContainerInterface $container): Command { echo 'Not call !'; return new ACommand('hola'); } public function configure(): CommandDefinition { echo 'call !'; $dto = new CommandDefinition('test', 'this is a sample'); $dto->addArgument(new InputArgument('hi')); $dto->addOption(new InputOption('anoption')); return $dto; } }
$application = new Application('My app');
$application->add(CommandBuilder::build(TestCommandFactory::class, $container));
$application->run();
// output : call !

The Versions

21/12 2016

dev-master

9999999-dev https://github.com/fezfez/symfony-console-di

Use symfony console with DI

  Sources   Download

The Requires

 

The Development Requires

by Stéphane Demonchaux

console symfony di

09/02 2016

0.1.0

0.1.0.0 https://github.com/fezfez/symfony-console-di

Use symfony console with DI

  Sources   Download

The Requires

 

The Development Requires

by Stéphane Demonchaux

console symfony di