Add example Symfony Console application

This commit is contained in:
Oliver Davies 2025-08-15 16:10:27 +01:00
parent a8defd7eae
commit d415966d94
5 changed files with 757 additions and 0 deletions

View file

@ -0,0 +1,20 @@
<?php
// https://symfony.com/doc/current/components/console/single_command_tool.html
require __DIR__.'/vendor/autoload.php';
use Symfony\Component\Console\Attribute\Argument;
use Symfony\Component\Console\Attribute\Option;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\SingleCommandApplication;
(new SingleCommandApplication())
->setName('My Super Command') // Optional
->setVersion('1.0.0') // Optional
->setCode(function (OutputInterface $output, #[Argument] string $foo = 'The directory', #[Option] string $bar = ''): int {
// output arguments and options
return 0;
})
->run();