kerasai / console-command-loader
Load services from the container as console commands Symfony.
Installs: 4
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 1
Open Issues: 0
pkg:composer/kerasai/console-command-loader
Requires
- symfony/console: ^4.4
- symfony/dependency-injection: ^4.4
Requires (Dev)
- consolidation/robo: ~1
- drupal/coder: ^8.3
- kerasai/robo-phpcs: ^0.0.4
This package is auto-updated.
Last update: 2025-10-22 00:01:05 UTC
README
This package adds the functionality to use services tagged as commands within a Symfony console application.
Usage
Set the "console.command" tag onto the service, and add a "command" value.
services: command.compute: class: \Kerasai\MyApp\Command\MyCommand public: true tags: - { name: 'console.command', command: 'my-command' }
And in the code that bootstraps the console application, create the service container and set the command loader.
<?php use Kerasai\ConsoleCommandLoader\TaggedCommandLoader; use Symfony\Component\Config\FileLocator; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; $containerBuilder = new ContainerBuilder(); $loader = new YamlFileLoader($containerBuilder, new FileLocator(__DIR__)); $loader->load('services.yml'); $commandLoader = new TaggedCommandLoader($containerBuilder); $app->setCommandLoader($commandLoader); $app->run();