1. Go to this page and download the library: Download yiisoft/yii-console 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/ */
yiisoft / yii-console example snippets
#!/usr/bin/env php
declare(strict_types=1);
use Yiisoft\Di\Container;
use Yiisoft\Di\ContainerConfig;
use Yiisoft\Yii\Console\Application;
use Yiisoft\Yii\Console\CommandLoader;
:create()),
// An array with command names as keys and service IDs as values:
['my/custom' => MyCustomCommand::class],
));
$app->run();
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Yiisoft\Yii\Console\ExitCode;
#[AsCommand(
name: 'my:custom',
description: 'Description of my custom command.'
)]
final class MyCustomCommand extends Command
{
protected function configure(): void
{
// ...
}
protected function execute(InputInterface $input, OutputInterface $output): int
{
// ...
return ExitCode::OK;
}
}