yiisoft / app-console
Template for console application
Fund package maintenance!
Opencollective
yiisoft
Installs: 71
Dependents: 0
Suggesters: 0
Security: 0
Stars: 21
Watchers: 16
Forks: 5
Open Issues: 0
Type:project
Requires
- php: ^8.0
- vlucas/phpdotenv: ^5.3
- yiisoft/aliases: ^3.0
- yiisoft/log: ^2.0
- yiisoft/log-target-file: ^3.0
- yiisoft/yii-console: ^2.0
- yiisoft/yii-runner-console: ^2.0
Requires (Dev)
- codeception/codeception: ^5.0
- codeception/module-asserts: ^3.0
- codeception/module-cli: ^2.0
- codeception/module-phpbrowser: ^3.0
- vimeo/psalm: ^4.30|^5.7
This package is auto-updated.
Last update: 2024-05-18 17:24:11 UTC
README
Yii Console Application
The package is a console application that can be used to perform common tasks in a Yii application.
Requirements
- PHP 8.0 or higher.
Installation
The package could be installed with Composer:
composer create-project --stability=dev yiisoft/app-console <your project>
General usage
Create command console
use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputDefinition; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Yiisoft\Yii\Console\ExitCode; final class Hello extends Command { protected static $defaultName = 'hello'; protected static $defaultDescription = 'An example command'; private string $sentence = 'sentence'; public function __construct() { parent::__construct(); } protected function configure(): void { $this->setDefinition( new InputDefinition([ new InputArgument($this->sentence, InputArgument::OPTIONAL, 'Sentence to say.', 'Hello!'), ]) ); } protected function execute(InputInterface $input, OutputInterface $output): int { $output->writeln("You said: {$input->getArgument('sentence')}"); return ExitCode::OK; } }
Using command console
$ ./yii Yii Console 1.0 Usage: command [options] [arguments] Options: -h, --help Display help for the given command. When no command is given display help for the list command -q, --quiet Do not output any message -V, --version Display this application version --ansi|--no-ansi Force (or disable --no-ansi) ANSI output -n, --no-interaction Do not ask any interactive question --config=CONFIG Set alternative configuration name -v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug Available commands: completion Dump the shell completion script hello An example command help Display help for a command list List commands serve Runs PHP built-in web server debug debug:container Show information about container debug:events Show information about events and listeners debug:reset Clear debug data
$ ./yii hello You said: Hello! $ ./yii hello 'Code something' You said: Code something
Documentation
If you need help or have a question, the Yii Forum is a good place for that. You may also check out other Yii Community Resources.
License
The Yii Console Application is free software. It is released under the terms of the BSD License.
Please see LICENSE
for more information.
Maintained by Yii Software.