mf / symfony-console-subscriber
Console Subscriber for Symfony Console
3.0.0
2022-07-25 14:08 UTC
Requires
- php: ^8.1
- symfony/console: ^5.0 || ^6.0
- symfony/event-dispatcher: ^5.0 || ^6.0
Requires (Dev)
- ergebnis/composer-normalize: ^2.28
- lmc/coding-standard: ^3.3
- mockery/mockery: ^1.4
- php-parallel-lint/php-parallel-lint: ^1.3
- phpstan/extension-installer: ^1.1
- phpstan/phpstan: ^1.8
- phpstan/phpstan-mockery: ^1.1
- phpstan/phpstan-phpunit: ^1.1
- phpunit/phpunit: ^9.5.20
README
Console Subscriber for Symfony Console.
Installation
composer require mf/symfony-console-subscriber
Usage
Comparision
It is same as using SymfonyStyle
directly, you just use EventDispatcher
to handle your events.
SymfonyStyle
$io->note('note'); // vs Dispatching $eventDispatcher->dispatch(new NoteEvent('Some note.'));
initialization
$io = new SymfonyStyle(); $subscriber = new ConsoleSubscriber(); $subscriber->setIo($io); $eventDispatcher->addSubscriber($subscriber);
dispatch
Note
$eventDispatcher->dispatch(new NoteEvent('Some note.'));
Progress
$items = [1, 2, 3]; $eventDispatcher->dispatch(new ProgressStartEvent($items)); foreach($items as $i) { // do something $eventDispatcher->dispatch(new ProgressAdvanceEvent()); } $eventDispatcher->dispatch(new ProgressFinishedEvent('All items were iterated!'));