PHPackages                             ssnepenthe/apheleia-cli - 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. ssnepenthe/apheleia-cli

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

ssnepenthe/apheleia-cli
=======================

An alternative syntax for writing WP-CLI commands

0.1.0(3y ago)2827[1 PRs](https://github.com/ssnepenthe/apheleia-cli/pulls)MITPHPPHP ^7.4 || ^8.0

Since Jul 5Pushed 2y ago1 watchersCompare

[ Source](https://github.com/ssnepenthe/apheleia-cli)[ Packagist](https://packagist.org/packages/ssnepenthe/apheleia-cli)[ RSS](/packages/ssnepenthe-apheleia-cli/feed)WikiDiscussions main Synced 1mo ago

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

apheleia-cli
============

[](#apheleia-cli)

Apheleia CLI provides an alternate approach to writing WP-CLI commands. It eliminates the need for docblock command definitions and should allow you to take full advantage of the autocomplete features in your favorite editor.

The syntax for Apheleia commands is loosely modeled after the [symfony/console](https://github.com/symfony/console) package.

Warning
-------

[](#warning)

This package is currently in development and is subject to breaking changes without notice until v1.0 has been tagged.

It is one in a series of [WordPress toys](https://github.com/ssnepenthe?tab=repositories&q=topic%3Atoy+topic%3Awordpress&type=&language=&sort=) I have been working on with the intention of exploring ways to modernize the feel of working with WordPress.

As the label suggests, it should be treated as a toy.

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

[](#installation)

```
composer require ssnepenthe/apheleia-cli
```

Usage
-----

[](#usage)

I think this is best explained through examples, so let's demonstrate some different ways we might implement the [`example hello` command from the WP-CLI handbook commands cookbook](https://make.wordpress.org/cli/handbook/guides/commands-cookbook/#annotating-with-phpdoc).

The preferred approach is to create self-contained command classes.

Extend the `Command` class using the `configure` method to define the command signature and the `handle` method to define the command logic to be executed when the command is called:

```
use ApheleiaCli\Argument;
use ApheleiaCli\Command;
use ApheleiaCli\Option;
use WP_CLI;

class HelloCommand extends Command
{
    public function configure(): void
    {
        $this->setName('example hello')
            ->setDescription('Prints a greeting.')
            ->addArgument(
                (new Argument('name'))
                    ->setDescription('The name of the person to greet.')
            )
            ->addOption(
                (new Option('type'))
                    ->setDescription('Whether or not to greet the person with success or error.')
                    ->setDefault('success')
                    ->setOptions('success', 'error')
            )
            ->setUsage("## EXAMPLES\n\n\twp example hello newman")
            ->setWhen('after_wp_load');
    }

    public function handle($args, $assocArgs)
    {
        [$name] = $args;

        $type = $assocArgs['type'];
        WP_CLI::$type("Hello, $name!");
    }
}
```

Commands are registered using the `CommandRegistry`.

```
use ApheleiaCli\CommandRegistry;

$registry = new CommandRegistry();

$registry->add(new HelloCommand());

$registry->initialize();
```

There is a significant difference between the command we have created and the original version: WP-CLI does not have any description text to display for the parent `example` command when you run `wp help example`.

There are a couple of different approaches we can take to fix this.

The first is to register a dedicated namespace alongside our `HelloCommand`:

```
$registry->namespace('example', 'Implements example command.');
$registry->add(new HelloCommand());
```

The second is to take advantage of command groups.

First we need to remove the parent command portion of our command name:

```
class HelloCommand extends Command
{
    public function configure(): void
    {
        $this->setName('hello')
            // etc...
            ;
    }

    // ...
}
```

And then we use the `group` method on our registry. The callback provided to the `group` method will receive a registry instance that has been scoped such that any commands added within the callback will automatically be registered as children of the `example` command:

```
$registry->group('example', 'Implements example command.', function (CommandRegistry $registry) {
    $registry->add(new HelloCommand());
});
```

It is also possible to define a command without extending the `Command` class:

```
$registry->add(
    (new Command())
        ->setName('hello')
        ->setDescription('Prints a greeting.')
        ->addArgument(
            (new Argument('name'))
                ->setDescription('The name of the person to greet.')
        )
        ->addOption(
            (new Option('type'))
                ->setDescription('Whether or not to greet the person with success or error.')
                ->setDefault('success')
                ->setOptions('success', 'error')
        )
        ->setUsage("## EXAMPLES\n\n\twp example hello newman")
        ->setWhen('after_wp_load')
        ->setHandler(function ($args, $assocArgs) {
            [$name] = $args;

            $type = $assocArgs['type'];
            WP_CLI::$type("Hello, $name!");
        })
);
```

Advanced Usage
--------------

[](#advanced-usage)

By default, command handlers should be written more-or-less the same as they would if you were working directly with WP-CLI. That is to say they should always expect to receive a list of command arguments as the first parameter and an associative array of command options as the second:

```
$command->setHandler(function (array $args, array $assocArgs) {
    // ...
});
```

However, commands can modify handler signatures by overriding their `handlerInvokerClass` property.

This package only ships with one alternative handler invoker: the `PhpDiHandlerInvoker`. It uses the [`php-di/invoker`](https://github.com/php-di/invoker) package to call command handlers.

Before it can be used, you must install `php-di/invoker`:

```
composer require php-di/invoker
```

Then set the handler invoker on your command (or a base command from which all of your commands extend):

```
use ApheleiaCli\Invoker\PhpDiHandlerInvoker;

class HelloCommand extends Command
{
    protected $handlerInvokerClass = PhpDiHandlerInvoker::class;

    // ...
}
```

With this in place, command handlers can now ask for command parameters by name:

```
class HelloCommand extends Command
{
    // ...

    public function handle($name, $type)
    {
        WP_CLI::$type("Hello, $name!");
    }
}
```

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity22

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity45

Maturing project, gaining track record

 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

Unknown

Total

1

Last Release

1403d ago

### Community

Maintainers

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

---

Top Contributors

[![ssnepenthe](https://avatars.githubusercontent.com/u/10903810?v=4)](https://github.com/ssnepenthe "ssnepenthe (69 commits)")

---

Tags

toywordpress

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Type Coverage Yes

### Embed Badge

![Health badge](/badges/ssnepenthe-apheleia-cli/health.svg)

```
[![Health](https://phpackages.com/badges/ssnepenthe-apheleia-cli/health.svg)](https://phpackages.com/packages/ssnepenthe-apheleia-cli)
```

###  Alternatives

[wp-cli/wp-cli

WP-CLI framework

5.0k17.2M319](/packages/wp-cli-wp-cli)[consolidation/annotated-command

Initialize Symfony Console commands from annotated command class methods.

22569.8M18](/packages/consolidation-annotated-command)[chi-teck/drupal-code-generator

Drupal code generator

26947.8M5](/packages/chi-teck-drupal-code-generator)[seld/cli-prompt

Allows you to prompt for user input on the command line, and optionally hide the characters they type

24725.8M17](/packages/seld-cli-prompt)[illuminate/console

The Illuminate Console package.

12944.1M5.1k](/packages/illuminate-console)[php-tui/php-tui

Comprehensive TUI library heavily influenced by Ratatui

589747.0k6](/packages/php-tui-php-tui)

PHPackages © 2026

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