PHPackages                             duncan3dc/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. [CLI &amp; Console](/categories/cli)
4. /
5. duncan3dc/console

ActiveLibrary[CLI &amp; Console](/categories/cli)

duncan3dc/console
=================

Create command line php applications using symfony/console

2.4.0(1y ago)16263.5k32Apache-2.0PHPPHP ^7.4 || ^8.0CI failing

Since Nov 23Pushed 5mo ago1 watchersCompare

[ Source](https://github.com/duncan3dc/console)[ Packagist](https://packagist.org/packages/duncan3dc/console)[ Docs](https://github.com/duncan3dc/console)[ RSS](/packages/duncan3dc-console/feed)WikiDiscussions main Synced 3w ago

READMEChangelogDependencies (17)Versions (32)Used By (2)

console
=======

[](#console)

Create command line php applications using symfony/console.
This is basically a fork of symfony/console which does things a little differently and adds some extra features.
Most of the features are useful when running commands in a background context (such as via crontab).

[![release](https://camo.githubusercontent.com/f86a82519b0a8d7b0ac53486fb7877a7483c82926e4e96770b28f9b4fdacc9ee/68747470733a2f2f706f7365722e707567782e6f72672f64756e63616e3364632f636f6e736f6c652f76657273696f6e2e737667)](https://packagist.org/packages/duncan3dc/console)[![build](https://github.com/duncan3dc/console/workflows/.github/workflows/buildcheck.yml/badge.svg?branch=master)](https://github.com/duncan3dc/console/actions?query=branch%3Amaster+workflow%3A.github%2Fworkflows%2Fbuildcheck.yml)[![coverage](https://camo.githubusercontent.com/4870fe735d6fd715cbc9bcbec7fbbb375fed7c451760b0ea7ae6c0ab08e66b1a/68747470733a2f2f636f6465636f762e696f2f67682f64756e63616e3364632f636f6e736f6c652f67726170682f62616467652e737667)](https://codecov.io/gh/duncan3dc/console)

Loading Commands
----------------

[](#loading-commands)

Commands can be automatically created from classes (meaning you don't need to call setName() inside your command class) using the following criteria:

- Files/classes must be named using CamelCase and must end in "Command" (with files having the .php extension)
- Each uppercase character will be converted to lowercase and preceded by a hyphen
- Directories will represent namespaces and each separater will be replaced with a colon
    Using the example below, the file src/commands/Category/Topic/RunCommand.php will create a command called category:topic:run

```
$application->loadCommands("src/commands");
```

*Of course, they can still be added the [symfony way](http://symfony.com/doc/current/components/console/introduction.html)*

Output
------

[](#output)

We use [league/climate](http://climate.thephpleague.com/) for terminal output, whilst also maintaining support for the [symfony way](http://symfony.com/doc/current/components/console/introduction.html#coloring-the-output).
So all of the following is possible:

```
$output->blue()->out("Blue? Wow!");
$output->dump($complexArrayForCLImate);
$output->writeln("I am a symfony/console error");
$output->error("I am a league/climate error");
```

Time Limit Commands
-------------------

[](#time-limit-commands)

Commands can limit how long they are run for, and end in a controlled way when the limit is reached.
Inside your command's class you can call the timeout() method and pass the number of seconds your command should run for.

```
class LimitedCommand extends \duncan3dc\Console\Command
{
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        while (true) {
            # If the command has been running for more than 10 minutes then end now
            if ($this->timeout(60 * 10)) {
                break;
            }
        }
    {
}
```

*This behaviour can be overridden by passing the `--no-time-limit` when running the application, this will cause the timeout() method to always return false*

Calling An Existing Command
---------------------------

[](#calling-an-existing-command)

The [symfony way](http://symfony.com/doc/current/components/console/introduction.html#calling-an-existing-command) of calling an existing command can be a little long-winded, with steps that seem unnecessary (eg, specifying the command name twice).
The runCommand() method provides a simplified way of doing this (using the example from the symfony docs):

```
$returnCode = $this->getApplication()->runCommand("demo:greet", [
    "name"      =>  "Fabien",
    "--yell"    =>  true,
], $input, $output);
```

*This also ensures any command event listeners that have been registered are called, which symfony does not do*

Command Locking
---------------

[](#command-locking)

All commands are automatically locked to prevent the same command being run simultaneously on the same host.
You can prevent particular commands from locking using the doNotLock() method:

```
protected function configure()
{
    $this
        ->doNotLock()
        ->setDescription("This command can run as many times as it likes, whether the previous run has finished or not");
}
```

*When a command cannot run it will exit with status 201, represented by the class constant Application::STATUS\_LOCKED*

Tab Completion
--------------

[](#tab-completion)

Tab completion is provided by [stecman/symfony-console-completion](https://github.com/stecman/symfony-console-completion) and instructions on setting it up for your application can be found in the README.md of that repository.

Namespace Listing
-----------------

[](#namespace-listing)

When you are entering commands in completion mode, it can often be useful to view the list of available commands in the namespace.
For example you might type `cat` then press tab which would complete the namespace, and the namespace separator:

```
:~$ console category:
```

But when you press tab again, you might be presented with a list of commands (or sub-namespaces) you don't entirely recognise. At this point the symfony way would be to delete the colon, run your cursor back to before your namespace, and type `list`:

```
:~$ console list category
```

Then having identified the command you need from the listing you would then need to type what you had earlier, before entering the command you require:

```
:~$ console category:
```

To make this use case easier, we have made running a command with a trailing colon, an alias for the list command shown above, so you can actually run:

```
:~$ console category:
```

Which will list all your available commands, then you can press the up arrow to retrieve that same command from your shell's history and carry on entering the command name, much quicker

duncan3dc/console for enterprise
--------------------------------

[](#duncan3dcconsole-for-enterprise)

Available as part of the Tidelift Subscription

The maintainers of duncan3dc/console and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/packagist-duncan3dc-console?utm_source=packagist-duncan3dc-console&utm_medium=referral&utm_campaign=readme)

###  Health Score

53

—

FairBetter than 96% of packages

Maintenance61

Regular maintenance activity

Popularity38

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity79

Established project with proven stability

 Bus Factor1

Top contributor holds 99.3% of commits — single point of failure

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 ~132 days

Recently: every ~349 days

Total

30

Last Release

378d ago

Major Versions

0.7.0 → 1.0.02018-05-04

1.4.0 → 2.0.02020-12-10

PHP version history (8 changes)0.1.0PHP &gt;=5.5.0

0.4.0PHP &gt;=5.6.0

0.5.0PHP ^5.6|^7.0

0.7.0PHP ^7.0

1.0.0PHP ^7.1

1.3.0PHP ^7.2

2.0.0PHP ^7.3

2.1.0PHP ^7.4 || ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/11dc66042513f11d1c99b1e6763f25dca84a3ff31cdbea3972b9b804a3d3d5e9?d=identicon)[duncan3dc](/maintainers/duncan3dc)

---

Top Contributors

[![duncan3dc](https://avatars.githubusercontent.com/u/546811?v=4)](https://github.com/duncan3dc "duncan3dc (152 commits)")[![peter279k](https://avatars.githubusercontent.com/u/9021747?v=4)](https://github.com/peter279k "peter279k (1 commits)")

---

Tags

cliphpsymfonycliconsolesymfony

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.4M196](/packages/sulu-sulu)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

585.4M517](/packages/shopware-core)[drupal/core

Drupal is an open source content management platform powering millions of websites and applications.

19564.8M1.6k](/packages/drupal-core)[open-dxp/opendxp

Content &amp; Product Management Framework (CMS/PIM)

9317.2k55](/packages/open-dxp-opendxp)[friendsoftypo3/content-blocks

TYPO3 CMS Content Blocks - Content Types API | Define reusable components via YAML

101466.4k45](/packages/friendsoftypo3-content-blocks)[drupal/core-recommended

Locked core dependencies; require this project INSTEAD OF drupal/core.

6941.5M396](/packages/drupal-core-recommended)

PHPackages © 2026

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