keiii / console-service-provider
This package is abandoned and no longer maintained.
No replacement package was suggested.
Console service provider for Silex
2.2
2016-11-26 20:33 UTC
Requires
- php: >=5.6
- symfony/console: ~3.1
Requires (Dev)
- friendsofphp/php-cs-fixer: ^1.12
- phpunit/phpunit: >=4
- silex/silex: ~2.0
- symfony/twig-bridge: ~3.1
- twig/twig: ^1.24
This package is not auto-updated.
Last update: 2023-03-15 18:15:21 UTC
README
Provides a Symfony\Component\Console
based console for Silex 2.
Download and Installation
$ composer require keiii/console-service-provider
Registering
#!/usr/bin/env php <?php $app = new Application(); $app->register(new ConsoleServiceProvider(), array( 'console.name' => 'MyApplication', 'console.version' => '1.0.0', )); $console = $app['console']; $console->add(new MyCommand()); $console->run();
Write commands
Your commands should extend KEIII\SilexConsole\Command
to have access getSilexApplication
, which returns the silex application.
Usage
Use the console just like any Symfony\Component
based console:
$ app/console my:command
Log exceptions
<?php $app['logger'] = $app::share(function () { return new MyLogger(); // \Psr\Log\LoggerInterface }); $app['console.log.listener'] = $app::share(function (Application $app) { return new \KEIII\SilexConsole\ConsoleLogListener($app['logger']); }); $app['dispatcher']->addSubscriber($app['console.log.listener']);