PHPackages                             eduavila/slim-commander - 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. eduavila/slim-commander

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

eduavila/slim-commander
=======================

A very simple structure for running CLI commands as part of your Slim Framework application

v0.2(5y ago)3818↓83.3%MITPHPPHP &gt;=7.1.0

Since Feb 20Pushed 5y agoCompare

[ Source](https://github.com/eduavila/slim-commander)[ Packagist](https://packagist.org/packages/eduavila/slim-commander)[ Docs](http://github.com/drewm/slim-commander)[ RSS](/packages/eduavila-slim-commander/feed)WikiDiscussions master Synced today

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

SlimCommander for Slim v4
=========================

[](#slimcommander-for-slim-v4)

A very simple structure for running CLI commands as part of your Slim Framework application v4.

This is not a console tool. It's just a parallel to the HTTP entry point into your application, enabling you to do things like create create scripts to be run as cronjobs or set up basic queue listeners.

Usage
-----

[](#usage)

Taking the structure of Slim-Skeleton as an example, your `public/index.php` does this:

```
require __DIR__ . '/../vendor/autoload.php';

session_start();

use DI\ContainerBuilder;
use Slim\App;
use SlimFacades\Facade;

// Instantiate container
// Container PHP-DI
$containerBuilder = new ContainerBuilder();

// Definitions PHP-DI
$containerDefinitions = require __DIR__ .'/container.php';

$containerBuilder->addDefinitions($containerDefinitions);

$container = $containerBuilder->build();
$app = $container->get(App::class);

// Register middleware
require __DIR__ . '/../src/middleware.php';

// Register routes
require __DIR__ . '/../src/routes.php';

// Run app
$app->run();
```

You need to create a new PHP script, similar to this, to serve as the entry point for your commands. It should be outside the `public` folder. Perhaps `src/cli.php`.

```
use DI\ContainerBuilder;

// Instancia container
// Container PHP-DI
$containerBuilder = new ContainerBuilder();

// Configura PHP-DI
$containerDefinitions = require __DIR__ .'/../src/app/container.php';

$containerBuilder->addDefinitions($containerDefinitions);
$container = $containerBuilder->build();

$app = new \DrewM\SlimCommander\App($container);

// Definições de comandos cli.
require __DIR__ . '/commands.php';

// Run app
$app->run($argv);
```

Instead of routes, you define commands in e.g. `src/commands.php`.

```
$app->command('HelloWorld', 'HelloWorld:greet', [
    'name',
]);
```

Arguments are:

1. Name of the command
2. The callback, defined in the same way as a regular Slim route callback
3. An array of expected argument names

In the above example, the first argument will be passed to the callback as `name`

Your callback gets the container passed to its constructor:

```
class HelloWorld
{
    private $container;

    public function __construct($container)
    {
        $this->container = $container;
    }

    public function greet($args)
    {
        echo "Hello " . $args['name'];
    }
}
```

Add it to your container, just as you would normally:

```
$container['HelloWorld'] = function ($container) {
    return new \App\Commands\HelloWorld($container);
};
```

And then you'd execute it with `php src/cli.php HelloWorld Fred`

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 54.5% 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 ~828 days

Total

2

Last Release

2172d ago

PHP version history (2 changes)v0.1PHP &gt;=5.5.0

v0.2PHP &gt;=7.1.0

### Community

Maintainers

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

---

Top Contributors

[![drewm](https://avatars.githubusercontent.com/u/225402?v=4)](https://github.com/drewm "drewm (6 commits)")[![eduavila](https://avatars.githubusercontent.com/u/1779843?v=4)](https://github.com/eduavila "eduavila (5 commits)")

---

Tags

clislim

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/eduavila-slim-commander/health.svg)

```
[![Health](https://phpackages.com/badges/eduavila-slim-commander/health.svg)](https://phpackages.com/packages/eduavila-slim-commander)
```

###  Alternatives

[symfony/console

Eases the creation of beautiful and testable command line interfaces

9.8k1.1B11.2k](/packages/symfony-console)[nunomaduro/collision

Cli error handling for console/command-line PHP applications.

4.6k331.8M8.4k](/packages/nunomaduro-collision)[nunomaduro/termwind

It's like Tailwind CSS, but for the console.

2.5k239.8M285](/packages/nunomaduro-termwind)[wp-cli/wp-cli

WP-CLI framework

5.0k17.2M319](/packages/wp-cli-wp-cli)[wp-cli/php-cli-tools

Console utilities for PHP

68325.0M364](/packages/wp-cli-php-cli-tools)[adrianfalleiro/slim-cli-runner

Run command line tasks for Slim PHP

4290.6k1](/packages/adrianfalleiro-slim-cli-runner)

PHPackages © 2026

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