This middleware will transform a CLI call into a GET Request.
composer require pavlakis/slim-cli
route / method / query string
php public/index.php /status GET event=true$app->add(new \pavlakis\cli\CliRequest());
$app->get('/status', 'PHPMinds\Action\EventStatusAction:dispatch')
->setName('status');final class EventStatusAction
{
...
public function dispatch(Request $request, Response $response, $args)
{
// ONLY WHEN CALLED THROUGH CLI
if (PHP_SAPI !== 'cli') {
return $response->withStatus(404)->withHeader('Location', '/404');
}
if (!$request->getParam('event')) {
return $response->withStatus(404)->withHeader('Location', '/404');
}
...
}
}Based on Bobby DeVeaux's (@bobbyjason) Gulp Skeleton