The minimalistic slim framework console implementation.
So, what exactly is this package?
Well, it is a simple library for Slim Framework 3 that allows you to call controller actions from the console.
It utilizes the strategy design pattern to provide a flexible way of parsing a given argv array.
You can find more information on the php argv variable here.
Further it provides a small middleware class, designed to stop web-access to these actions.
Run composer require gameplayjdk/slim-console
.
Yes, it's that simple.
Initial setup:
<?php
// ...
$configuration = [];
$console = new \Slim\Console\Console();
if ($console->isSupported()) {
$configuration['environment'] = $console->getEnvironment($argv);
}
$configuration['settings'] = [
// ...
];
$app = new \Slim\App($configuration);
// ...
Middleware usage:
<?php
// ...
$app->get('/cli/some-command', \App\Controller\CliController::class . ':someCommandAction')
->add($console->getMiddleware());
// ...
Call that action from the console:
php app.php cli some-command
The MIT license.
- Write up some unittests
- More
ArgvParserInterface
implementations