saxulum / saxulum-console
Saxulum Console Provider
Installs: 48 445
Dependents: 9
Suggesters: 9
Security: 0
Stars: 5
Watchers: 0
Forks: 2
Open Issues: 1
Requires
- php: >=5.3.3,<8.0
- pimple/pimple: >=2.1,<4
- saxulum/saxulum-classfinder: ~1.1,>=1.1.1
- symfony/console: ~2.3|~3.0
- symfony/finder: ~2.3|~3.0
Requires (Dev)
- phpunit/phpunit: ~4.0
README
works with plain silex-php
Features
- Add symfony console
Requirements
- PHP 5.3+
- Pimple 2.1+
- Saxulum ClassFinder 1.0+
- Symfony Console 2.3+
- Symfony Finder 2.3+
Installation
Through Composer as saxulum/saxulum-console.
$container->register(new ConsoleProvider());
With translation cache (faster)
use Pimple\Container;
use Saxulum\Console\Silex\Provider\ConsoleProvider;
$container = new Container();
$container->register(new ConsoleProvider(), array(
'console.cache' => '/path/to/cache'
));
debug == true
: the cache file will be build at each loaddebug == false
: the cache file will be build if not exists, delete it if its out of sync
Without translation cache (slower)
use Pimple\Container;
use Saxulum\Console\Silex\Provider\ConsoleProvider;
$container = new Container();
$container->register(new ConsoleProvider());
Usage
Register a command
$container['console.commands'] = $container->extend('console.commands', function ($commands) use ($container) {
$command = new SampleCommand;
$command->setContainer($container);
$commands[] = $command;
return $commands;
});
Register a path
One of their parent classes has to be: Saxulum\Console\Command\AbstractPimpleCommand
$container['console.command.paths'] = $container->extend('console.command.paths', function ($paths) {
$paths[] = __DIR__ . '/../../Command';
return $paths;
});
Run the console
$container['console']->run();
Copyright
- Dominik Zogg dominik.zogg@gmail.com