All Projects → pavlakis → Slim Cli

pavlakis / Slim Cli

Licence: bsd-3-clause
A Slim 3 middleware enabling a mock HTTP request to be made through the CLI.

Projects that are alternatives of or similar to Slim Cli

Guzzle Advanced Throttle
A Guzzle middleware that can throttle requests according to (multiple) defined rules. It is also possible to define a caching strategy, e.g. get the response from cache when the rate limit is exceeded or always get a cached value to spare your rate limits. Using wildcards in host names is also supported.
Stars: ✭ 120 (+224.32%)
Mutual labels:  middleware, request
Wretch Middlewares
Collection of middlewares for the Wretch library. 🎁
Stars: ✭ 42 (+13.51%)
Mutual labels:  middleware, request
Cors
🔮Supported(Laravel/Lumen/PSR-15/Swoft/Slim/ThinkPHP) - PHP CORS (Cross-origin resource sharing) middleware.
Stars: ✭ 266 (+618.92%)
Mutual labels:  middleware, request
Redux Query
A library for managing network state in Redux
Stars: ✭ 1,055 (+2751.35%)
Mutual labels:  middleware, request
Concurrency Logger
Log HTTP requests/responses separately, visualize their concurrency and report logs/errors in context of a request.
Stars: ✭ 400 (+981.08%)
Mutual labels:  middleware, request
Django Login Required Middleware
Requires login to all requests through middleware.
Stars: ✭ 20 (-45.95%)
Mutual labels:  middleware
Graphql Upload
Middleware and an Upload scalar to add support for GraphQL multipart requests (file uploads via queries and mutations) to various GoLang GraphQL servers
Stars: ✭ 32 (-13.51%)
Mutual labels:  middleware
Grpc Tools
A suite of gRPC debugging tools. Like Fiddler/Charles but for gRPC.
Stars: ✭ 881 (+2281.08%)
Mutual labels:  middleware
Shardingsphere Elasticjob
Distributed scheduled job framework
Stars: ✭ 7,369 (+19816.22%)
Mutual labels:  middleware
Nex
Aiming to simplify the construction of JSON API service
Stars: ✭ 35 (-5.41%)
Mutual labels:  middleware
Sos
Sandia OpenSHMEM is an implementation of the OpenSHMEM specification over multiple Networking APIs, including Portals 4, the Open Fabric Interface (OFI), and UCX. Please click on the Wiki tab for help with building and using SOS.
Stars: ✭ 34 (-8.11%)
Mutual labels:  middleware
Micro Xrce Dds Client
Micro XRCE-DDS Client repository
Stars: ✭ 30 (-18.92%)
Mutual labels:  middleware
Go Bootstrap
Easy way to bootstrap a web server in Go (Routing|Middleware|Https)
Stars: ✭ 27 (-27.03%)
Mutual labels:  middleware
Govalidator
Validate Golang request data with simple rules. Highly inspired by Laravel's request validation.
Stars: ✭ 969 (+2518.92%)
Mutual labels:  request
Gentleman
Full-featured, plugin-driven, extensible HTTP client toolkit for Go
Stars: ✭ 886 (+2294.59%)
Mutual labels:  middleware
Copper
Copper is a set of Go packages that help you build backend APIs quickly and with less boilerplate.
Stars: ✭ 35 (-5.41%)
Mutual labels:  middleware
Blazar
Pre-Render Pages on the Fly in Laravel
Stars: ✭ 14 (-62.16%)
Mutual labels:  middleware
Whoops
PSR-15 middleware to use Whoops as error handler
Stars: ✭ 29 (-21.62%)
Mutual labels:  middleware
Create Request
Apply interceptors to `fetch` and create a custom request function.
Stars: ✭ 34 (-8.11%)
Mutual labels:  request
Adroit
ADR/PSR-7 middleware
Stars: ✭ 28 (-24.32%)
Mutual labels:  middleware

pavlakis/slim-cli

Build Status Total Downloads Latest Stable Version codecov PHPStan

Slim 3 Framework CLI Request Middleware

This middleware will transform a CLI call into a Request.

Note: Added support for the following HTTP Request methods:

    'GET',
    'HEAD',
    'POST',
    'PUT',
    'DELETE',
    'CONNECT',
    'OPTIONS',
    'TRACE',
    'PATCH',

Install

Via Composer

composer require pavlakis/slim-cli

Usage

Pass the parameters in this order

route / method / query string

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:

$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:

// 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

$ composer test

Contributing

Please see CONTRIBUTING for details.

Credits

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

License

The BSD 3-Clause License. Please see License File for more information.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].