Skip to content
This repository has been archived by the owner on Oct 27, 2019. It is now read-only.

teraone/slim-cli

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status

Slim 3 Framework CLI Request Middleware

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.

Add it with composer

composer require teraone/slim-cli

Pass the parameters in this order

route / query string

php public/index.php /status event=true

Add it in the middleware section of your application

$app->add(new \Teraone\SlimCli\CliRequest());

Pass a route to test it with

$app->get('/status', 'YourNameSpace\YourController:yourMethod')
    ->setName('status');

Check you're only using a CLI call

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');
        }

        ...

    }

}

Credits

Based on Bobby DeVeaux's (@bobbyjason) Gulp Skeleton

About

A Slim 3 middleware enabling a mock GET request to be made through the CLI.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%