This middleware will transform a CLI call into a GET Request. It is based on https://github.com/pavlakis/slim-cli but does not use the method paramter.
composer require teraone/slim-cli
route / query string
php public/index.php /status event=true
$app->add(new \Teraone\SlimCli\CliRequest());
$app->get('/status', 'YourNameSpace\YourController:yourMethod')
->setName('status');
final class YourController
{
...
public function yourMethod(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