PHPackages                             suin/cakephp-subcommand-injector - 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. suin/cakephp-subcommand-injector

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

suin/cakephp-subcommand-injector
================================

CakePHP Subcommand Injector make it possible that automatical adding Task classes as subcommands of a Shell class.

1.0.2(8y ago)412MITPHPPHP &gt;=7.1

Since Apr 30Pushed 8y ago1 watchersCompare

[ Source](https://github.com/suin/cakephp-subcommand-injector)[ Packagist](https://packagist.org/packages/suin/cakephp-subcommand-injector)[ RSS](/packages/suin-cakephp-subcommand-injector/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependencies (5)Versions (4)Used By (0)

CakePHP Subcommand Injector
===========================

[](#cakephp-subcommand-injector)

[![travis-ci-badge](https://camo.githubusercontent.com/03083174fea7b547199fdc2e71e8750538531199a54302f953bb42b744139a4c/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f7375696e2f63616b657068702d737562636f6d6d616e642d696e6a6563746f722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/suin/cakephp-subcommand-injector) [![packagist-dt-badge](https://camo.githubusercontent.com/a46fda7025d8547837b2e538a51f6de29f853b3c3aa6e6063e8f26325a87b7f4/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7375696e2f63616b657068702d737562636f6d6d616e642d696e6a6563746f722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/suin/cakephp-subcommand-injector) [![license-badge](https://camo.githubusercontent.com/7bbde0f56397d24f1248df0819c2bf5886dd3b9fae1eeebb9cf0c16a89ba53e9/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f7375696e2f63616b657068702d737562636f6d6d616e642d696e6a6563746f722e7376673f7374796c653d666c61742d737175617265)](LICENSE.md) [![release-version-badge](https://camo.githubusercontent.com/2f5023a8f136933ffef809a37ccd9913ba7cc928a9f3eaf6c33feb8a7ce7b366/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7375696e2f63616b657068702d737562636f6d6d616e642d696e6a6563746f722e7376673f7374796c653d666c61742d737175617265266c6162656c3d72656c65617365)](https://packagist.org/packages/suin/cakephp-subcommand-injector) [![code-climate-maintainability-badge](https://camo.githubusercontent.com/eeef0b9cd28f6e300df147bdbcd76eb7bea2554f6d808770c674bc6965fba904/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636c696d6174652f6d61696e7461696e6162696c6974792f7375696e2f63616b657068702d737562636f6d6d616e642d696e6a6563746f722e7376673f7374796c653d666c61742d737175617265)](https://codeclimate.com/github/suin/cakephp-subcommand-injector) [![code-climate-test-coverage-badge](https://camo.githubusercontent.com/eb73f66da68b523d1b3e9e344b6191e0bc8cb42cbd28b06629984690279293cc/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636c696d6174652f632f7375696e2f63616b657068702d737562636f6d6d616e642d696e6a6563746f722e7376673f7374796c653d666c61742d737175617265)](https://codeclimate.com/github/suin/cakephp-subcommand-injector) [![php-version-badge](https://camo.githubusercontent.com/61f179d1b1436b138341b880dedd8caafa6890c4d4d0f870d2216c35f06e1010/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f7375696e2f63616b657068702d737562636f6d6d616e642d696e6a6563746f722e7376673f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/61f179d1b1436b138341b880dedd8caafa6890c4d4d0f870d2216c35f06e1010/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f7375696e2f63616b657068702d737562636f6d6d616e642d696e6a6563746f722e7376673f7374796c653d666c61742d737175617265)

CakePHP Subcommand Injector make it possible that automatical adding Task classes as subcommands of a Shell class.

Features
--------

[](#features)

1. Automatically add subcommands to a shell.
2. You don't [have to write pipe code for each Tasks](https://book.cakephp.org/3.0/en/console-and-shells/option-parsers.html#adding-subcommands).

### How it works

[](#how-it-works)

1. Find shell task classes from a specific directory.
2. Automatically add them to a shell as subcommands.

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

[](#installation)

```
$ composer require suin/cakephp-subcommand-injector
```

Examples
--------

[](#examples)

```
class ExampleShell extends \Cake\Console\Shell
{
    /**
     * @var SubcommandInjector
     */
    private $subcommandInjector;

    public function __construct(
        \Cake\Console\ConsoleIo $io = null,
        \Cake\ORM\Locator\LocatorInterface $locator = null
    )
    {
        parent::__construct($io, $locator);

        // 1. Initialize subcommand injector as a member of Shell class
        $this->subcommandInjector = SubcommandInjector::build(
            // Define how you find task classes:
            new TaskClassesConformingToPsr4(
                __DIR__ . '/my-app/src/',
                'MyApp\\',
                __DIR__ . '/my-app/src/*/*Task.php'
            ),
            // Define mapping rules between task class and subcommand name:
            new NamingRuleByPatternMatching(
                'MyApp\\{module_name}\\{task_name}Task',
                '{module_name}:{task_name}'
            )
        );
    }

    public function initialize()
    {
        // 2. Add tasks to this shell
        $this->subcommandInjector->addTasksTo($this);
        parent::initialize();
    }

    public function getOptionParser()
    {
        $parser = parent::getOptionParser();
        // 3. Add subcommands to this shell's parser
        return $this->subcommandInjector->addSubcommandsTo($this, $parser);
    }
}
```

See more examples, visit [./example](./example) folder.

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more details.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](.github/CONTRIBUTING.md) for more details.

###  Health Score

27

—

LowBetter than 47% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 100% 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 ~1 days

Total

3

Last Release

2981d ago

### Community

Maintainers

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

---

Top Contributors

[![suin](https://avatars.githubusercontent.com/u/855338?v=4)](https://github.com/suin "suin (14 commits)")

---

Tags

cakephpcakephp3

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/suin-cakephp-subcommand-injector/health.svg)

```
[![Health](https://phpackages.com/badges/suin-cakephp-subcommand-injector/health.svg)](https://phpackages.com/packages/suin-cakephp-subcommand-injector)
```

###  Alternatives

[dereuromark/cakephp-ide-helper

CakePHP IdeHelper Plugin to improve auto-completion

1882.3M40](/packages/dereuromark-cakephp-ide-helper)[cakephp/debug_kit

CakePHP Debug Kit

84114.4M160](/packages/cakephp-debug-kit)[cakephp/bake

Bake plugin for CakePHP

11211.7M190](/packages/cakephp-bake)[dereuromark/cakephp-tools

A CakePHP plugin containing lots of useful and reusable tools

333972.2k49](/packages/dereuromark-cakephp-tools)[dereuromark/cakephp-queue

The Queue plugin for CakePHP provides deferred task execution.

308914.0k25](/packages/dereuromark-cakephp-queue)[dereuromark/cakephp-tinyauth

A CakePHP plugin to handle user authentication and authorization the easy way.

131237.3k13](/packages/dereuromark-cakephp-tinyauth)

PHPackages © 2026

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