All Projects → yiisoft → yii-console

yiisoft / yii-console

Licence: BSD-3-Clause License
Yii console components

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to yii-console

ConEmuIntegration
Using the console emulator ConEmu within Visual Studio. This project integrates the console emulator ConEmu in Visual Studio.
Stars: ✭ 36 (-25%)
Mutual labels:  console
WeConsole
功能全面、界面与体验对标 Chrome devtools 的可定制化的小程序开发调试面板
Stars: ✭ 137 (+185.42%)
Mutual labels:  console
slim-command
Useful commands for slim application
Stars: ✭ 13 (-72.92%)
Mutual labels:  console
pretty-routes
Display your Laravel routes in the console, but make it pretty. 😎
Stars: ✭ 627 (+1206.25%)
Mutual labels:  console
demo
Yii 3 demo application
Stars: ✭ 259 (+439.58%)
Mutual labels:  yii3
preact-component-console
A console emulator for preact.
Stars: ✭ 29 (-39.58%)
Mutual labels:  console
UE4 MagicConsole
Enhanced UE4 output log widget
Stars: ✭ 71 (+47.92%)
Mutual labels:  console
var-dumper
Helper for dumping variable for debug purposes
Stars: ✭ 13 (-72.92%)
Mutual labels:  yii3
RecoverPy
🙈 Interactively find and recover deleted or 👉 overwritten 👈 files from your terminal
Stars: ✭ 189 (+293.75%)
Mutual labels:  console
circumflex
🌿 It's Hacker News in your terminal
Stars: ✭ 43 (-10.42%)
Mutual labels:  console
laravel-web-console
💻 Web console for your Laravel application
Stars: ✭ 142 (+195.83%)
Mutual labels:  console
contour
Modern C++ Terminal Emulator
Stars: ✭ 761 (+1485.42%)
Mutual labels:  console
console.img
🎉 Display a picture in the Chrome browser console
Stars: ✭ 44 (-8.33%)
Mutual labels:  console
jira-cli
🔥 [WIP] Feature-rich interactive Jira command line.
Stars: ✭ 809 (+1585.42%)
Mutual labels:  console
ctable
C library to print nicely formatted tables
Stars: ✭ 13 (-72.92%)
Mutual labels:  console
injector
PSR-11 compatible injector
Stars: ✭ 33 (-31.25%)
Mutual labels:  yii3
pyeez
easy elegant representation on console
Stars: ✭ 14 (-70.83%)
Mutual labels:  console
ascii chart
Nice-looking lightweight console ASCII line charts ╭┈╯. Port of kroitor/asciichart.
Stars: ✭ 24 (-50%)
Mutual labels:  console
command-line
⌨ Command line options and arguments parser.
Stars: ✭ 35 (-27.08%)
Mutual labels:  console
strings
String helper methods and an inflector
Stars: ✭ 31 (-35.42%)
Mutual labels:  yii3

Yii Framework Console


Latest Stable Version Total Downloads Build status Code Coverage Scrutinizer Quality Score Mutation testing badge static analysis type-coverage

This Yii Framework package provides a console that could be added to an application.

Requirements

  • PHP 7.4 or higher.

Installation

The package could be installed with composer:

composer require yiisoft/yii-console --prefer-dist

General usage

In case you use one of Yii 3 standard application templates, console could be accessed as ./yii <command>.

If not, then in the simplest use case in your console entry script do the following:

#!/usr/bin/env php
<?php

declare(strict_types=1);

use Yiisoft\Di\Container;
use Yiisoft\Di\ContainerConfig;
use Yiisoft\Yii\Console\Application;
use Yiisoft\Yii\Console\CommandLoader;

require_once __DIR__ . '/vendor/autoload.php';

$app = new Application();

$app->setCommandLoader(new CommandLoader(
    // Any container implementing `Psr\Container\ContainerInterface` for example:
    new Container(ContainerConfig::create()),
    // An array with command names as keys and service IDs as values:
    ['my/custom' => MyCustomCommand::class],
));

$app->run();

Since \Yiisoft\Yii\Console\CommandLoader uses lazy loading of commands, it is necessary to specify the name and description in static properties when creating a command:

use Symfony\Component\Console\Command\Command;
use Yiisoft\Yii\Console\ExitCode;

final class MyCustomCommand extends Command
{
    protected static $defaultName = 'my/custom';
    protected static $defaultDescription = 'Description of my custom command.';
    
    protected function configure(): void
    {
        // ...
    }
    
    protected function execute(InputInterface $input, OutputInterface $output): int
    {
        // ...
        return ExitCode::OK;
    }
}

Run the console entry script with your command:

your-console-entry-script my/custom

When naming commands, a slash / should be used as a separator. For example: user/create, user/delete, etc.

Since the package is based on Symfony Console component, refer to its documentation for details on how to use the binary and create your own commands.

Aliases and hidden commands

To configure commands, set the names and aliases in \Yiisoft\Yii\Console\CommandLoader configuration. Names and aliases from the command class itself are always ignored.

The command can be marked as hidden by prefixing its name with |.

'yiisoft/yii-console' => [
    'commands' => [
        'hello' => Hello::class, // name: 'hello', aliases: [], hidden: false
        'start|run|s|r' => Run::class, // name: 'start', aliases: ['run', 's', 'r'], hidden: false
        '|hack|h' => Hack::class, // name: 'hack', aliases: ['h'], hidden: true
    ],
],

Testing

Unit testing

The package is tested with PHPUnit. To run tests:

./vendor/bin/phpunit

Mutation testing

The package tests are checked with Infection mutation framework with Infection Static Analysis Plugin. To run it:

./vendor/bin/roave-infection-static-analysis-plugin

Static analysis

The code is statically analyzed with Psalm. To run static analysis:

./vendor/bin/psalm

License

The Yii Framework Console is free software. It is released under the terms of the BSD License. Please see LICENSE for more information.

Maintained by Yii Software.

Support the project

Open Collective

Follow updates

Official website Twitter Telegram Facebook Slack

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].