yuralukashik/short-commands-bundle

Short commands for Symfony Console

Installs: 15 390

Dependents: 0

Suggesters: 0

Security: 0

Stars: 3

Watchers: 1

Forks: 0

Open Issues: 1

Type:bundle

pkg:composer/yuralukashik/short-commands-bundle

1.2.1 2022-08-12 14:48 UTC

This package is auto-updated.

Last update: 2025-11-29 03:24:47 UTC


README

  • Install ShortCommandsBundle.
composer require yuralukashik/short-commands-bundle
  • Register a folder with your commands, see config.yml:
short_commands:
  directories:
    - "%kernel.root_dir%/../examples"
  • Create a PHP file, for example examples/example:use-filesystem-service.php. Name of the file example:use-filesystem-service is going to be the name of the command.
  • Return a function from that file with all dependencies as arguments:
<?php

use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Console\Output\OutputInterface;

return function (
    Filesystem $filesystem,
    OutputInterface $output,
    string $name = 'Unknown'
) {
    $currentFileExists = $filesystem->exists(__FILE__);
    $message = $currentFileExists
        ? 'current file really exists'
        : 'current file does not exist';
    $output->writeln("Hey {$name}!");
    $output->writeln("I've just checked and {$message}");
};

Check out /examples for more examples.