yuralukashik / short-commands-bundle
Short commands for Symfony Console
Installs: 15 389
Dependents: 0
Suggesters: 0
Security: 0
Stars: 3
Watchers: 2
Forks: 0
Open Issues: 1
Type:bundle
Requires
- php: >=7.4.2
- symfony/config: ~5.4|~6.0
- symfony/console: ~5.4|~6.0
- symfony/dependency-injection: ~5.4|~6.0
- symfony/framework-bundle: ~5.4|~6.0
- symfony/http-kernel: ~5.4|~6.0
- symfony/yaml: ~5.4|~6.0
This package is auto-updated.
Last update: 2024-03-29 22:14:40 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 fileexample: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.