Skip to content

Load services from the container as console commands Symfony.

Notifications You must be signed in to change notification settings

kerasai/console-command-loader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Command Loader

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();

About

Load services from the container as console commands Symfony.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages