Skip to content
This repository has been archived by the owner on Mar 2, 2023. It is now read-only.

KEIII/ConsoleServiceProvider

 
 

Repository files navigation

ConsoleServiceProvider

Build Status

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']);

About

A Console service provider for Silex

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 98.4%
  • Shell 1.5%
  • HTML 0.1%