PHPackages                             yiisoft/app-console - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. yiisoft/app-console

ActiveProject[Framework](/categories/framework)

yiisoft/app-console
===================

Template for console application

1.0.2(2mo ago)301926[2 issues](https://github.com/yiisoft/app-console/issues)BSD-3-ClausePHPPHP 8.1 - 8.5CI passing

Since Jun 19Pushed 2mo ago12 watchersCompare

[ Source](https://github.com/yiisoft/app-console)[ Packagist](https://packagist.org/packages/yiisoft/app-console)[ Docs](https://www.yiiframework.com/)[ GitHub Sponsors](https://github.com/sponsors/yiisoft)[ OpenCollective](https://opencollective.com/yiisoft)[ RSS](/packages/yiisoft-app-console/feed)WikiDiscussions master Synced today

READMEChangelog (3)Dependencies (11)Versions (4)Used By (0)

 [ ![Yii](https://camo.githubusercontent.com/8317c17418b39410a660f5149071d26c5023c0d5fb2b7ebb771324812f666d73/68747470733a2f2f796969736f66742e6769746875622e696f2f646f63732f696d616765732f7969695f6c6f676f2e737667) ](https://github.com/yiisoft)

Yii Console Application
=======================

[](#yii-console-application)

[![Latest Stable Version](https://camo.githubusercontent.com/f3d949aff1f98b345e2e3f17b9aefe04f078aedf42951c8523c8f66826647e9d/68747470733a2f2f706f7365722e707567782e6f72672f796969736f66742f6170702d636f6e736f6c652f762f737461626c652e706e67)](https://packagist.org/packages/yiisoft/app-console)[![Total Downloads](https://camo.githubusercontent.com/7c0db8a77eea6bc1c3a2ae647cfe973609cf61d4c710e11af7fd4860e814b5d0/68747470733a2f2f706f7365722e707567782e6f72672f796969736f66742f6170702d636f6e736f6c652f646f776e6c6f6164732e706e67)](https://packagist.org/packages/yiisoft/app-console)[![Build status](https://github.com/yiisoft/app-console/actions/workflows/build.yml/badge.svg?branch=master)](https://github.com/yiisoft/app-console/actions/workflows/build.yml?query=branch%3Amaster)[![Static analysis](https://github.com/yiisoft/app-console/actions/workflows/static.yml/badge.svg?branch=master)](https://github.com/yiisoft/app-console/actions/workflows/static.yml?query=branch%3Amaster)[![type-coverage](https://camo.githubusercontent.com/63161caf5b6bab80c72cb83421c10d3b16c084e0a7616746c38fb114e4602988/68747470733a2f2f73686570686572642e6465762f6769746875622f796969736f66742f6170702d636f6e736f6c652f636f7665726167652e737667)](https://shepherd.dev/github/yiisoft/app-console)

The package is a **console only** application template that can be used to perform common tasks in a Yii application. If you need classic web or API please start with corresponding templates:

- [Classic web application template](https://github.com/yiisoft/app)
- [API application template](https://github.com/yiisoft/app-api)

It is based on [Yii console runner](https://github.com/yiisoft/yii-runner-console) that is used in the entry command script, `./yii`. You are free to adjust any part of this template including the entry command script to suit your needs.

Requirements
------------

[](#requirements)

- PHP 8.1 - 8.5.

Creating a project
------------------

[](#creating-a-project)

Use [Composer](https://getcomposer.org) to create new project from this template:

```
composer create-project yiisoft/app-console
```

General usage
-------------

[](#general-usage)

Console is available as `./yii` from the root directory of the application:

```
$ ./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
  echo        An example command that echoes exactly what it is told to.
  help        Display help for a command
  list        List commands
  serve       Runs PHP built-in web server
```

Help for specific command could be displayed by adding `--help` to the command itself:

```
$ ./yii echo --help

Description:
  An example command that echoes exactly what it is told to.

Usage:
  echo []

Arguments:
  sentence              Sentence to say. [default: "Hello!"]

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
```

Using the command is like the following:

```
$ ./yii echo
You said: Hello!

$ ./yii echo 'Code something'
You said: Code something
```

Environments
------------

[](#environments)

Out of the box, three environments are available:

- dev — for development.
- prod — for production.
- test — for running tests.

Config files for these are in `config/environments`.

Environment could be chosen by setting `YII_ENV`:

```
YII_ENV=prod ./yii
```

Extra debugging
---------------

[](#extra-debugging)

To enable validation of container and events, set `YII_DEBUG` environment variable:

```
YII_DEBUG=1 ./yii
```

Creating your own command
-------------------------

[](#creating-your-own-command)

Commands are placed into `src/Command`. Let's see how `hello` command is implemented in `src/Command/HelloCommand.php`:

```
namespace App\Command;

use Symfony\Component\Console\Attribute\AsCommand;
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;

#[AsCommand(
    name: 'echo',
    description: 'An example command that echoes exactly what it is told to.'
)]
final class EchoCommand extends Command
{
    private string $sentence = 'sentence';

    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;
    }
}
```

To register the command, add it to `config/commands.php`:

```
use App\Command\EchoCommand;

return [
    'echo' => EchoCommand::class,
];
```

> Info: Yii console is based on Symfony console so for additional usage documentation, please follow [Yii console](https://github.com/yiisoft/yii-console) and [Symfony console guide](https://symfony.com/doc/current/console.html).

Events
------

[](#events)

The application raises `ApplicationStartup` before and `ApplicationShutdown` after running a command.

Tests
-----

[](#tests)

The template comes with ready to use [Codeception](https://codeception.com/) configuration. In order to execute tests run:

```
composer run serve > ./runtime/yii.log 2>&1 &
vendor/bin/codecept run
```

Static analysis
---------------

[](#static-analysis)

The code is statically analyzed with [Psalm](https://psalm.dev/). To run static analysis:

```
./vendor/bin/psalm
```

License
-------

[](#license)

The Yii Console Application is free software. It is released under the terms of the BSD License. Please see [`LICENSE`](./LICENSE.md) for more information.

Maintained by [Yii Software](https://www.yiiframework.com/).

Support the project
-------------------

[](#support-the-project)

[![Open Collective](https://camo.githubusercontent.com/a2b15f8e2268d4e3842e00d41ff7a57cce2ad8bd8d8769c5dc4fa05a546a4f62/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4f70656e253230436f6c6c6563746976652d73706f6e736f722d3765616466313f6c6f676f3d6f70656e253230636f6c6c656374697665266c6f676f436f6c6f723d376561646631266c6162656c436f6c6f723d353535353535)](https://opencollective.com/yiisoft)

Follow updates
--------------

[](#follow-updates)

[![Official website](https://camo.githubusercontent.com/d6b0929173e28cc627430d2519ca1853466a70f37395877eaf4820cb3e1e1909/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f506f77657265645f62792d5969695f4672616d65776f726b2d677265656e2e7376673f7374796c653d666c6174)](https://www.yiiframework.com/)[![Twitter](https://camo.githubusercontent.com/d077c362ac639792171af8bc002ee827816733dfc0925f70b557e6d151022226/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f747769747465722d666f6c6c6f772d3144413146323f6c6f676f3d74776974746572266c6f676f436f6c6f723d314441314632266c6162656c436f6c6f723d3535353535353f7374796c653d666c6174)](https://twitter.com/yiiframework)[![Telegram](https://camo.githubusercontent.com/4e38dd12535575c39c65bea7119b95e663abb2d1f4e3d669a27bbda07ef603f0/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f74656c656772616d2d6a6f696e2d3144413146323f7374796c653d666c6174266c6f676f3d74656c656772616d)](https://t.me/yii3en)[![Facebook](https://camo.githubusercontent.com/48204e301b34b29b0815854544f04c337fc0692096cab35e9a1f8c53a42c2307/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f66616365626f6f6b2d6a6f696e2d3144413146323f7374796c653d666c6174266c6f676f3d66616365626f6f6b266c6f676f436f6c6f723d666666666666)](https://www.facebook.com/groups/yiitalk)[![Slack](https://camo.githubusercontent.com/1a3645ba1c97e6684d0349bc478201e1621ba0d3efad516d81035364d442bad7/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f736c61636b2d6a6f696e2d3144413146323f7374796c653d666c6174266c6f676f3d736c61636b)](https://yiiframework.com/go/slack)

###  Health Score

49

—

FairBetter than 95% of packages

Maintenance82

Actively maintained with recent releases

Popularity24

Limited adoption so far

Community24

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor2

2 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~276 days

Total

3

Last Release

88d ago

PHP version history (2 changes)1.0.0PHP ^8.1

1.0.2PHP 8.1 - 8.5

### Community

Maintainers

![](https://www.gravatar.com/avatar/261a6249c6f605f3956a2fae40fbb813f6b2e1e6f2bf806180c851a965426e54?d=identicon)[cebe](/maintainers/cebe)

![](https://www.gravatar.com/avatar/fc29e4e7068a00fe9b9db37b8aadda1db6020adcacef810461e47b99c2b150e6?d=identicon)[samdark](/maintainers/samdark)

![](https://www.gravatar.com/avatar/ccb75e3312d6bd454ea445ea308139fd185a4ca906ca5df21cc66e6a35de25a3?d=identicon)[SilverFire](/maintainers/SilverFire)

![](https://www.gravatar.com/avatar/99106256c24a8cb23871b99fa90e48f37f1aa71608c185759b7d2a88683a5918?d=identicon)[hiqsol](/maintainers/hiqsol)

---

Top Contributors

[![vjik](https://avatars.githubusercontent.com/u/525501?v=4)](https://github.com/vjik "vjik (16 commits)")[![luizcmarin](https://avatars.githubusercontent.com/u/67489841?v=4)](https://github.com/luizcmarin "luizcmarin (5 commits)")[![samdark](https://avatars.githubusercontent.com/u/47294?v=4)](https://github.com/samdark "samdark (5 commits)")[![terabytesoftw](https://avatars.githubusercontent.com/u/42547589?v=4)](https://github.com/terabytesoftw "terabytesoftw (4 commits)")[![xepozz](https://avatars.githubusercontent.com/u/6815714?v=4)](https://github.com/xepozz "xepozz (4 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (2 commits)")[![tomaszkane](https://avatars.githubusercontent.com/u/1530354?v=4)](https://github.com/tomaszkane "tomaszkane (1 commits)")[![StyleCIBot](https://avatars.githubusercontent.com/u/11048387?v=4)](https://github.com/StyleCIBot "StyleCIBot (1 commits)")[![jeffersoncechinel](https://avatars.githubusercontent.com/u/13597855?v=4)](https://github.com/jeffersoncechinel "jeffersoncechinel (1 commits)")

---

Tags

appapplicationconsoleproject-templatetemplateyii3consoletemplateyiiapplication

###  Code Quality

TestsCodeception

Static AnalysisPsalm

Type Coverage Yes

### Embed Badge

![Health badge](/badges/yiisoft-app-console/health.svg)

```
[![Health](https://phpackages.com/badges/yiisoft-app-console/health.svg)](https://phpackages.com/packages/yiisoft-app-console)
```

###  Alternatives

[opulence/opulence

The Opulence PHP framework

72128.9k2](/packages/opulence-opulence)[yiisoft/app

Yii3 web application template

35011.3k](/packages/yiisoft-app)[yiisoft/yii-console

Symfony console wrapper with additional features

70389.5k24](/packages/yiisoft-yii-console)[yiisoft/yii-runner-console

Console application runner

10178.9k8](/packages/yiisoft-yii-runner-console)[yiisoft/app-api

Yii3 API project template

971.5k](/packages/yiisoft-app-api)[yiisoft/yii-http

Yii HTTP Application

10203.2k13](/packages/yiisoft-yii-http)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
