PHP code example of baethon / symfony-console-input
1. Go to this page and download the library: Download baethon/symfony-console-input library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
baethon / symfony-console-input example snippets
use Baethon\Symfony\Console\Input\Attributes\Argument;
use Baethon\Symfony\Console\Input\Attributes\Option;
readonly class MyCommandInput
{
public function __construct(
#[Argument]
public string $name, // A
use Baethon\Symfony\Console\Input\Attributes\InputData;
use Baethon\Symfony\Console\Input\UsesInputData;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Attribute\AsCommand;
#[AsCommand(name: 'my-command')]
class MyCommand extends Command
{
use UsesInputData;
#[InputData]
private MyCommandInput $input;
protected function execute(InputInterface $input, OutputInterface $output): int
{
$output->writeln("Name: {$this->input->name}");
$output->writeln("Age: {$this->input->age}");
return Command::SUCCESS;
}
}