PHPackages                             circli/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. circli/console

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

circli/console
==============

wrapper around symfony console to better support containers

2.4.0(3w ago)016.8k↓61.9%12MITPHPPHP ^8.2CI passing

Since Jul 21Pushed 3w ago1 watchersCompare

[ Source](https://github.com/circli/console)[ Packagist](https://packagist.org/packages/circli/console)[ RSS](/packages/circli-console/feed)WikiDiscussions main Synced 2d ago

READMEChangelog (8)Dependencies (8)Versions (10)Used By (2)

Circli Console - Wrapper around symfony console
===============================================

[](#circli-console---wrapper-around-symfony-console)

[![Latest Version](https://camo.githubusercontent.com/02e74561453c8693fd0fc33c328fe01b975057bbc54a63f3420ad1f61f9103fe/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f636972636c692f636f6e736f6c652e7376673f7374796c653d666c61742d737175617265)](https://github.com/circli/console/releases)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE)[![Build Status](https://github.com/circli/console/actions/workflows/unit-tests.yml/badge.svg)](https://github.com/circli/console/actions/workflows/unit-tests.yml)[![Coverage Status](https://camo.githubusercontent.com/333efd851535bca4b216377698e722a4738f79dfb1f32c3efea16c9930edb23d/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f636972636c692f636f6e736f6c652f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/circli/console?branch=master)

I created this package to have a more lightweight initialization of symfony console applications. It's a bit annoying if a class dose auto connect to something remote, and it needs todo that when you list the commands or run something not connected to the remote service. So I split the definition and command into 2 parts one for the definition and one for the command. And the command is not initialized until it's needed.

Installation
------------

[](#installation)

```
composer require circli/console

```

Usage
-----

[](#usage)

#### Definition

[](#definition)

The definition object handles everything related to how the command is called. And **must** extend `\Circli\Console\Definition`.

#### Command

[](#command)

The command can be anything `callable` and **must** return an integer.

So any class you want to use as a command need to implement `__invoke(InputInterface $input, OutputInterface $output): int`.

### Most basic definition

[](#most-basic-definition)

```
class ExampleCommandDefinition extends \Circli\Console\Definition
{
    protected function configure(): void
    {
        $this->setName('example:command');
        $this->setCommand(function($input, $output) {
            return 0;
        });
    }
}

$application = new Application();
$application->addDefinition(new ExampleCommandDefinition());

$application->run();
```

### Using custom input

[](#using-custom-input)

You can transform input into custom input types to have better type hinting and control over what is passed into a command

```
class ExampleInput extends \Circli\Console\AbstractInput
{
    public function getFrom(): \DateTimeInterface
    {
        $rawDate = $this->getArgument('from') ?: 'now';

        return new \DateTimeImmutable($rawDate);
    }
}

class ExampleCommandDefinition extends \Circli\Console\Definition
{
    protected function configure(): void
    {
        $this->setName('example:command');
        $this->addArgument('from', InputArgument::REQUIRED);
        $this->setCommand(function(ExampleInput $input, $output) {
            $from = $input->getFrom();
            return 0;
        });
    }

    public function transformInput(InputInterface $input, OutputInterface $output): InputInterface
    {
        return new ExampleInput();
    }

}
```

### Using psr container

[](#using-psr-container)

This is a basic implementation to get lazy initialization to work.

If you pass in the container command resolver it will try resolving the command when it's needed.

You can write your own resolver logic if you don't want to pass in the container like this

```
use Circli\Console\Application;
use Circli\Console\ContainerCommandResolver;
use Circli\Console\Definition;

$application = new Application(new ContainerCommandResolver($psr11container));
$application->addDefinition(new class extends Definition {
    protected function configure(): void
    {
        $this->setName('example:command');
        $this->setCommand('keyInContainer');
    }
});
$application->run();
```

### Using with regular Symfony console

[](#using-with-regular-symfony-console)

```
use Symfony\Component\Console\Application;
use Circli\Console\Command;

$application = new Application();
$application->add(new \Circli\Console\Command(new CmdDefinition()));
$application->run();
```

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE) for more information.

###  Health Score

56

—

FairBetter than 97% of packages

Maintenance95

Actively maintained with recent releases

Popularity27

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity73

Established project with proven stability

 Bus Factor1

Top contributor holds 80% 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 ~307 days

Recently: every ~239 days

Total

8

Last Release

23d ago

Major Versions

1.1.1 → 2.0.02023-10-26

PHP version history (4 changes)1.0.0PHP &gt;=7.3

1.1.0PHP ^7.4 || ^8.0

2.0.0PHP ^8.1

2.4.0PHP ^8.2

### Community

Maintainers

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

---

Top Contributors

[![sunkan](https://avatars.githubusercontent.com/u/568492?v=4)](https://github.com/sunkan "sunkan (28 commits)")[![runar-stefna](https://avatars.githubusercontent.com/u/171600457?v=4)](https://github.com/runar-stefna "runar-stefna (7 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[illuminate/console

The Illuminate Console package.

13046.0M6.5k](/packages/illuminate-console)

PHPackages © 2026

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