{"id":14966403,"url":"https://github.com/yiisoft/yii-console","last_synced_at":"2025-05-16T05:04:13.113Z","repository":{"id":37790086,"uuid":"140871025","full_name":"yiisoft/yii-console","owner":"yiisoft","description":"Yii console components","archived":false,"fork":false,"pushed_at":"2025-04-04T07:09:04.000Z","size":270,"stargazers_count":65,"open_issues_count":8,"forks_count":32,"subscribers_count":22,"default_branch":"master","last_synced_at":"2025-05-12T15:53:28.862Z","etag":null,"topics":["console","hacktoberfest","yii3"],"latest_commit_sha":null,"homepage":"https://www.yiiframework.com/","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yiisoft.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":".github/CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":".github/SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"open_collective":"yiisoft","github":["yiisoft"]}},"created_at":"2018-07-13T16:42:51.000Z","updated_at":"2025-04-10T06:25:35.000Z","dependencies_parsed_at":"2023-11-09T15:04:44.675Z","dependency_job_id":"e8972787-7dde-4d30-9ece-bbf887ab1a62","html_url":"https://github.com/yiisoft/yii-console","commit_stats":{"total_commits":212,"total_committers":29,"mean_commits":7.310344827586207,"dds":0.6745283018867925,"last_synced_commit":"a6d3c60a9d29da5e15311f7fd31aaddbf9bd7f90"},"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yiisoft%2Fyii-console","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yiisoft%2Fyii-console/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yiisoft%2Fyii-console/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yiisoft%2Fyii-console/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yiisoft","download_url":"https://codeload.github.com/yiisoft/yii-console/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254043215,"owners_count":22004911,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["console","hacktoberfest","yii3"],"created_at":"2024-09-24T13:36:20.081Z","updated_at":"2025-05-16T05:04:13.075Z","avatar_url":"https://github.com/yiisoft.png","language":"PHP","funding_links":["https://opencollective.com/yiisoft","https://github.com/sponsors/yiisoft"],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://github.com/yiisoft\" target=\"_blank\"\u003e\n        \u003cimg src=\"https://yiisoft.github.io/docs/images/yii_logo.svg\" height=\"100px\" alt=\"Yii\"\u003e\n    \u003c/a\u003e\n    \u003ch1 align=\"center\"\u003eYii Console\u003c/h1\u003e\n    \u003cbr\u003e\n\u003c/p\u003e\n\n[![Latest Stable Version](https://poser.pugx.org/yiisoft/yii-console/v)](https://packagist.org/packages/yiisoft/yii-console)\n[![Total Downloads](https://poser.pugx.org/yiisoft/yii-console/downloads)](https://packagist.org/packages/yiisoft/yii-console)\n[![Build status](https://github.com/yiisoft/yii-console/actions/workflows/build.yml/badge.svg)](https://github.com/yiisoft/yii-console/actions/workflows/build.yml)\n[![Code Coverage](https://codecov.io/gh/yiisoft/yii-console/branch/master/graph/badge.svg)](https://codecov.io/gh/yiisoft/yii-console)\n[![Mutation testing badge](https://img.shields.io/endpoint?style=flat\u0026url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgithub.com%2Fyiisoft%2Fyii-console%2Fmaster)](https://dashboard.stryker-mutator.io/reports/github.com/yiisoft/yii-console/master)\n[![static analysis](https://github.com/yiisoft/yii-console/workflows/static%20analysis/badge.svg)](https://github.com/yiisoft/yii-console/actions?query=workflow%3A%22static+analysis%22)\n[![type-coverage](https://shepherd.dev/github/yiisoft/yii-console/coverage.svg)](https://shepherd.dev/github/yiisoft/yii-console)\n\nYii Console package provides a console that could be added to an application. This console is based on\n[Symfony Console](https://github.com/symfony/console). The following extra features are added:\n\n- lazy command loader;\n- `SymfonyEventDispatcher` class that allows to use any [PSR-14](https://www.php-fig.org/psr/psr-14/) compatible event\n  dispatcher with Symfony console;\n- `ErrorListener` for logging console errors to any [PSR-3](https://www.php-fig.org/psr/psr-3/) compatible logger;\n- console command `serve` that runs PHP built-in web server;\n- raises events `ApplicationStartup` and `ApplicationShutdown` in console application;\n- class `ExitCode` that contains constants for defining console command exit codes;\n- `ConsoleBufferedOutput` that wraps `ConsoleOutput` and buffers console output.  \n\n## Requirements\n\n- PHP 8.0 or higher.\n\n## Installation\n\nThe package could be installed with [Composer](https://getcomposer.org):\n\n```shell\ncomposer require yiisoft/yii-console\n```\n\n## General usage\n\nIn case you use one of Yii 3 standard application templates, console could be accessed as `./yii \u003ccommand\u003e`.\n\nIf not, then in the simplest use case in your console entry script do the following:\n\n```php\n#!/usr/bin/env php\n\u003c?php\n\ndeclare(strict_types=1);\n\nuse Yiisoft\\Di\\Container;\nuse Yiisoft\\Di\\ContainerConfig;\nuse Yiisoft\\Yii\\Console\\Application;\nuse Yiisoft\\Yii\\Console\\CommandLoader;\n\nrequire_once __DIR__ . '/vendor/autoload.php';\n\n$app = new Application();\n\n$app-\u003esetCommandLoader(new CommandLoader(\n    // Any container implementing `Psr\\Container\\ContainerInterface` for example:\n    new Container(ContainerConfig::create()),\n    // An array with command names as keys and service IDs as values:\n    ['my/custom' =\u003e MyCustomCommand::class],\n));\n\n$app-\u003erun();\n```\n\nSince `\\Yiisoft\\Yii\\Console\\CommandLoader` uses lazy loading of commands, it's necessary\nto specify the name and description in static properties when creating a command:\n\n```php\nuse Symfony\\Component\\Console\\Attribute\\AsCommand;\nuse Symfony\\Component\\Console\\Command\\Command;\nuse Yiisoft\\Yii\\Console\\ExitCode;\n\n\n#[AsCommand(\n    name: 'my:custom',\n    description: 'Description of my custom command.'\n)]\nfinal class MyCustomCommand extends Command\n{    \n    protected function configure(): void\n    {\n        // ...\n    }\n    \n    protected function execute(InputInterface $input, OutputInterface $output): int\n    {\n        // ...\n        return ExitCode::OK;\n    }\n}\n```\n\nRun the console entry script with your command:\n\n```shell\nyour-console-entry-script my/custom\n```\n\n\u003e When naming commands use `:` as a separator. For example: `user:create`, `user:delete`, etc.\n\nSince the package is based on [Symfony Console component](https://symfony.com/doc/current/components/console.html),\nrefer to its documentation for details on how to use the binary and create your own commands.\n\n### Aliases and hidden commands\n\nTo configure commands, set the names and aliases in `\\Yiisoft\\Yii\\Console\\CommandLoader` configuration.\nNames and aliases from the command class itself are always ignored.\n\nThe command can be marked as hidden by prefixing its name with `|`.\n\n```php\n'yiisoft/yii-console' =\u003e [\n    'commands' =\u003e [\n        'hello' =\u003e Hello::class, // name: 'hello', aliases: [], hidden: false\n        'start|run|s|r' =\u003e Run::class, // name: 'start', aliases: ['run', 's', 'r'], hidden: false\n        '|hack|h' =\u003e Hack::class, // name: 'hack', aliases: ['h'], hidden: true\n    ],\n],\n```\n\n### Runs PHP built-in web server\n\nYou can start local built-in web development server using the command:\n\n```shell\n./yii serve\n```\n\nYour application will be accessible in your web browser at \u003chttp://localhost:8080\u003e by default.\nTo configure default settings, set the options in `\\Yiisoft\\Yii\\Console\\CommandLoader` configuration.\n\n```php\n'yiisoft/yii-console' =\u003e [\n    'serve' =\u003e [\n        'appRootPath' =\u003e null,\n        'options' =\u003e [\n            'address' =\u003e '127.0.0.1',\n            'port' =\u003e '8080',\n            'docroot' =\u003e 'public',\n            'router' =\u003e 'public/index.php',\n        ],\n    ],\n],\n```\n\nAlternatively, you can pass the settings through the console options.\n\n\u003e Tip: To run a web server with XDebug enabled, pass `--xdebug 1` to the command.\n\nTo see the available options, run `./yii serve --help`.\n\n## Documentation\n\n- [Internals](docs/internals.md)\n\nIf you need help or have a question, the [Yii Forum](https://forum.yiiframework.com/c/yii-3-0/63) is a good place for that.\nYou may also check out other [Yii Community Resources](https://www.yiiframework.com/community).\n\n## License\n\nThe Yii Console is free software. It is released under the terms of the BSD License.\nPlease see [`LICENSE`](./LICENSE.md) for more information.\n\nMaintained by [Yii Software](https://www.yiiframework.com/).\n\n## Support the project\n\n[![Open Collective](https://img.shields.io/badge/Open%20Collective-sponsor-7eadf1?logo=open%20collective\u0026logoColor=7eadf1\u0026labelColor=555555)](https://opencollective.com/yiisoft)\n\n## Follow updates\n\n[![Official website](https://img.shields.io/badge/Powered_by-Yii_Framework-green.svg?style=flat)](https://www.yiiframework.com/)\n[![Twitter](https://img.shields.io/badge/twitter-follow-1DA1F2?logo=twitter\u0026logoColor=1DA1F2\u0026labelColor=555555?style=flat)](https://twitter.com/yiiframework)\n[![Telegram](https://img.shields.io/badge/telegram-join-1DA1F2?style=flat\u0026logo=telegram)](https://t.me/yii3en)\n[![Facebook](https://img.shields.io/badge/facebook-join-1DA1F2?style=flat\u0026logo=facebook\u0026logoColor=ffffff)](https://www.facebook.com/groups/yiitalk)\n[![Slack](https://img.shields.io/badge/slack-join-1DA1F2?style=flat\u0026logo=slack)](https://yiiframework.com/go/slack)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyiisoft%2Fyii-console","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyiisoft%2Fyii-console","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyiisoft%2Fyii-console/lists"}