saxulum/saxulum-console

3.1.1 2015-12-01 11:57 UTC

README

works with plain silex-php

Build Status Total Downloads Latest Stable Version Scrutinizer Code Quality

Features

  • Add symfony console

Requirements

  • PHP 5.3+
  • Saxulum ClassFinder 1.0+
  • Symfony Console 2.3+
  • Symfony Finder 2.3+

Installation

Through Composer as saxulum/saxulum-console.

$app->register(new ConsoleProvider());

With translation cache (faster)

use Saxulum\Console\Silex\Provider\ConsoleProvider;

$app->register(new ConsoleProvider(), array(
    'console.cache' => '/path/to/cache'
));
  • debug == true: the cache file will be build at each load
  • debug == false: the cache file will be build if not exists, delete it if its out of sync

Without translation cache (slower)

use Saxulum\Console\Silex\Provider\ConsoleProvider;

$app->register(new ConsoleProvider());

Usage

Register a command

$app['console.commands'] = $app->share(
    $app->extend('console.commands', function ($commands) use ($app) {
        $command = new SampleCommand;
        $command->setContainer($app);
        $commands[] = $command;

        return $commands;
    })
);

Register a path

One of their parent classes has to be: Saxulum\Console\Command\AbstractPimpleCommand

$app['console.command.paths'] = $app->share($app->extend('console.command.paths', function ($paths) {
    $paths[] = __DIR__ . '/../../Command';

    return $paths;
}));

Run the console

$app->boot();
$app['console']->run();

Copyright