2017 © Pedro Peláez
 

library slim-cli

Making a mock GET request through the CLI and enabling the same application entry point on CLI scripts.

image

pavlakis/slim-cli

Making a mock GET request through the CLI and enabling the same application entry point on CLI scripts.

  • Sunday, February 18, 2018
  • by pavlakis
  • Repository
  • 3 Watchers
  • 32 Stars
  • 13,448 Installations
  • PHP
  • 3 Dependents
  • 0 Suggesters
  • 7 Forks
  • 2 Open issues
  • 9 Versions
  • 11 % Grown

The README.md

pavlakis/slim-cli

Build Status Total Downloads Latest Stable Version codecov PHPStan, (*1)

Slim 3 Framework CLI Request Middleware, (*2)

This middleware will transform a CLI call into a Request., (*3)

Install

Via Composer, (*4)

composer require pavlakis/slim-cli

Usage

Pass the parameters in this order

route / method / query string, (*5)

php public/index.php /status GET event=true

Add it in the middleware section of your application

$app->add(new \pavlakis\cli\CliRequest());

Adding custom parameters:, (*6)

$app->add(
    new \pavlakis\cli\CliRequest(
        new EnvironmentProperties(['SERVER_PORT' => 9000])
    )
);

Pass a route to test it with


$app->get('/status', 'PHPMinds\Action\EventStatusAction:dispatch') ->setName('status');

Check you're only using a CLI call

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

        ...

    }

}

Or we can use a PHP Server Interface (SAPI) Middleware to do the SAPI check adding by adding it to a route:, (*7)

// By default returns a 403 if SAPI not part of the whitelist
$app->get('/status', 'PHPMinds\Action\EventStatusAction:dispatch')
    ->add(new Pavlakis\Middleware\Server\Sapi(["cli"]))

Testing

bash $ composer test, (*8)

Contributing

Please see CONTRIBUTING for details., (*9)

Credits

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

License

The BSD 3-Clause License. Please see License File for more information., (*11)

The Versions

18/02 2018

dev-master

9999999-dev http://github.com/pavlakis/slim-cli

Making a mock GET request through the CLI and enabling the same application entry point on CLI scripts.

  Sources   Download

BSD-3-Clause

The Requires

  • php ^5.5|^5.6|^7.0|^7.1

 

The Development Requires

middleware framework cli slim

18/02 2018

dev-develop

dev-develop http://github.com/pavlakis/slim-cli

Making a mock GET request through the CLI and enabling the same application entry point on CLI scripts.

  Sources   Download

BSD-3-Clause

The Requires

  • php ^5.5|^5.6|^7.0|^7.1

 

The Development Requires

middleware framework cli slim

18/02 2018

dev-feature/add-checks-for-72

dev-feature/add-checks-for-72 http://github.com/pavlakis/slim-cli

Making a mock GET request through the CLI and enabling the same application entry point on CLI scripts.

  Sources   Download

BSD-3-Clause

The Requires

  • php ^5.5|^5.6|^7.0|^7.1

 

The Development Requires

middleware framework cli slim

30/04 2017

dev-feature/codecov-badge

dev-feature/codecov-badge http://github.com/pavlakis/slim-cli

Making a mock GET request through the CLI and enabling the same application entry point on CLI scripts.

  Sources   Download

BSD-3-Clause

The Requires

  • php ^5.5|^5.6|^7.0|^7.1

 

The Development Requires

middleware framework cli slim

30/01 2017

1.0.4

1.0.4.0 http://github.com/pavlakis/slim-cli

Making a mock GET request through the CLI and enabling the same application entry point on CLI scripts.

  Sources   Download

BSD-3-Clause

The Requires

  • php ^5.5|^5.6|^7.0|^7.1

 

The Development Requires

middleware framework cli slim

22/02 2016

1.0.3

1.0.3.0 http://github.com/pavlakis/slim-cli

Making a mock GET request through the CLI and enabling the same application entry point on CLI scripts.

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.5.0

 

The Development Requires

middleware framework cli slim

29/01 2016

1.0.2

1.0.2.0 http://github.com/pavlakis/slim-cli

Making a mock GET request through the CLI and enabling the same application entry point on CLI scripts.

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.5.0

 

The Development Requires

middleware framework cli slim

02/01 2016

1.0.1

1.0.1.0 http://github.com/pavlakis/slim-cli

Making a mock GET request through the CLI and enabling the same application entry point on CLI scripts.

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.5.0

 

The Development Requires

middleware framework cli slim

28/12 2015

1.0

1.0.0.0 http://github.com/pavlakis/slim-cli

Making a mock GET request through the CLI and enabling the same application entry point on CLI scripts.

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.5.0

 

The Development Requires

middleware framework cli slim