Skip to content

Commit 45fa990

Browse files
committed
document event and console tagged config
1 parent 93903eb commit 45fa990

File tree

1 file changed

+120
-7
lines changed

1 file changed

+120
-7
lines changed

docs/README.md

Lines changed: 120 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -752,13 +752,10 @@ The event dispatcher is available as `Psr\EventDispatcher\EventDispatcherInterfa
752752

753753
````yaml
754754
# config/autoload/dependencies.{prod,local,dev}.yaml
755-
parameters:
756-
app-events:
757-
event-listeners:
758-
# Full\Name\To\SomeEvent or some.event.identifier
759-
some-event:
760-
- 'App\Application\EventListener\SomeEventListener'
761-
- 'App\Application\EventListener\SomeOtherEventListener'
755+
services:
756+
App\Application\EventListener\SomeEventListener:
757+
tags:
758+
- { name: 'event_listener', event: 'Full\Name\SomeEventClass' }
762759
````
763760

764761
#### ** Zend style yaml **
@@ -927,6 +924,122 @@ bin console config:show:container
927924
````
928925
![Show container command](/images/cli-show-container.jpg)
929926

927+
### Clear Config Cache
928+
929+
````php
930+
bin console config:clear-cache
931+
````
932+
933+
### Custom Console Command
934+
935+
Console tool is built in on top of Symfony Console Component, to createnew command you need to extend from Symfony
936+
Console Command Class
937+
938+
````php
939+
<?php
940+
941+
declare(strict_types=1);
942+
943+
namespace Some\Namespace;
944+
945+
use Symfony\Component\Console\Command\Command;
946+
use Symfony\Component\Console\Input\InputInterface;
947+
use Symfony\Component\Console\Output\OutputInterface;
948+
949+
final class SomeCommand extends Command
950+
{
951+
public CONST = 'some:command:name';
952+
953+
protected function configure()
954+
{
955+
$this->setName(self::NAME)
956+
->setDescription('Show all available services inner container.');
957+
}
958+
959+
protected function execute(InputInterface $input, OutputInterface $output)
960+
{
961+
// do some stuff here.
962+
}
963+
}
964+
````
965+
966+
#### Config
967+
968+
<!-- tabs:start -->
969+
970+
#### ** Symfony style yaml **
971+
972+
````yaml
973+
# config/autoload/dependencies.{prod,local,dev}.yaml
974+
services:
975+
App\Application\EventListener\SomeCommand:
976+
tags:
977+
- { name: 'console.command', command: 'some:command:name' }
978+
````
979+
980+
#### ** Zend style yaml **
981+
982+
````yaml
983+
# config/autoload/dependencies.{prod,local,dev}.yaml
984+
console:
985+
commands:
986+
'some:command:name': App\Application\EventListener\SomeCommand
987+
dependencies:
988+
invokables:
989+
App\Application\EventListener\SomeCommand: App\Application\EventListener\SomeCommand
990+
991+
````
992+
993+
#### ** Symfony style php **
994+
995+
````php
996+
<?php
997+
// config/autoload/dependencies.{prod,dev,local}.php
998+
999+
declare(strict_types=1);
1000+
1001+
return [
1002+
'services' => [
1003+
App\Application\EventListener\SomeCommand::class => [
1004+
'class' => App\Application\EventListener\SomeCommand::class,
1005+
'tags' => [
1006+
[
1007+
'name' => 'console.command',
1008+
'command' => App\Application\EventListener\SomeCommand::NAME
1009+
]
1010+
]
1011+
]
1012+
]
1013+
];
1014+
````
1015+
1016+
#### ** Zend style php **
1017+
1018+
````php
1019+
<?php
1020+
// config/autoload/dependencies.{prod,dev,local}.php
1021+
1022+
declare(strict_types=1);
1023+
1024+
return [
1025+
'console' => [
1026+
'commands' => [
1027+
App\Application\EventListener\SomeCommand::NAME =>
1028+
App\Application\EventListener\SomeCommand::class
1029+
]
1030+
],
1031+
'dependencies' => [
1032+
'invokables' => [
1033+
App\Application\EventListener\SomeCommand::class =>
1034+
App\Application\EventListener\SomeCommand::clsss
1035+
]
1036+
]
1037+
];
1038+
````
1039+
1040+
<!-- tabs:end -->
1041+
1042+
9301043
###### Special thanks
9311044

9321045
* **JetBrains:** Thanks for supporting us with the All Products Pack License for Open Source

0 commit comments

Comments
 (0)