PHPackages                             pavlakis/slim-cli - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. pavlakis/slim-cli

ActiveLibrary[Framework](/categories/framework)

pavlakis/slim-cli
=================

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

1.2(6y ago)3691.9k↓37.5%5[3 issues](https://github.com/pavlakis/slim-cli/issues)3BSD-3-ClausePHPPHP &gt;=5.5.0CI failing

Since Dec 28Pushed 5y ago2 watchersCompare

[ Source](https://github.com/pavlakis/slim-cli)[ Packagist](https://packagist.org/packages/pavlakis/slim-cli)[ Docs](http://github.com/pavlakis/slim-cli)[ RSS](/packages/pavlakis-slim-cli/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (7)Dependencies (3)Versions (11)Used By (3)

pavlakis/slim-cli
=================

[](#pavlakisslim-cli)

[![Build Status](https://camo.githubusercontent.com/301f40e3b7a4d19c277f5ae9edbf21079f2c732ed6f7482a8f2989dee0d99967/68747470733a2f2f7472617669732d63692e6f72672f7061766c616b69732f736c696d2d636c692e737667)](https://travis-ci.org/pavlakis/slim-cli)[![Total Downloads](https://camo.githubusercontent.com/b9d0e675e4328a5508c3d2ab3bac5c59b9deb96874cef382536992e9c4f621af/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7061766c616b69732f736c696d2d636c692e737667)](https://packagist.org/packages/pavlakis/slim-cli)[![Latest Stable Version](https://camo.githubusercontent.com/c9e6fc5eaeb68cba1a636bf0896a446815334b0856b1198a3436053ae8004847/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7061766c616b69732f736c696d2d636c692e737667)](https://packagist.org/packages/pavlakis/slim-cli)[![codecov](https://camo.githubusercontent.com/a8a1ddc2dedca2650c6add2eb6c51fc06e4b64eb6019dddfee82fdccdc743dca/68747470733a2f2f636f6465636f762e696f2f67682f7061766c616b69732f736c696d2d636c692f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/pavlakis/slim-cli)[![PHPStan](https://camo.githubusercontent.com/441b5874ce4df0a2defc892979c96c46889b69cb32119d04f0b48626349f8bc9/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d656e61626c65642d627269676874677265656e2e7376673f7374796c653d666c6174)](https://github.com/phpstan/phpstan)

Slim 3 Framework CLI Request Middleware

This middleware will transform a CLI call into a Request.

Install
-------

[](#install)

Via Composer

```
composer require pavlakis/slim-cli

```

Usage
-----

[](#usage)

### Pass the parameters in this order

[](#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

[](#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

[](#pass-a-route-to-test-it-with)

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

### Check you're only using a CLI call

[](#check-youre-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](https://github.com/pavlakis/php-server-interface-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
-------

[](#testing)

```
$ composer test
```

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Credits
-------

[](#credits)

- [Antonios Pavlakis](https://github.com/pavlakis)

> Based on Bobby DeVeaux's ([@bobbyjason](https://twitter.com/bobbyjason)) [Gulp Skeleton](https://github.com/dvomedia/gulp-skeleton/blob/master/web/index.php)

License
-------

[](#license)

The BSD 3-Clause License. Please see [License File](LICENSE) for more information.

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity41

Moderate usage in the ecosystem

Community15

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~248 days

Recently: every ~420 days

Total

8

Last Release

2055d ago

Major Versions

1.2 → 2.x-dev2020-10-01

PHP version history (3 changes)1.0PHP &gt;=5.5.0

1.0.4PHP ^5.5|^5.6|^7.0|^7.1

2.x-devPHP ^7.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/b0cd55a30199337cee36f2dcf8c4026f13f3b9e3ee281ca571d3752291ea25f7?d=identicon)[pavlakis](/maintainers/pavlakis)

---

Top Contributors

[![pavlakis](https://avatars.githubusercontent.com/u/673223?v=4)](https://github.com/pavlakis "pavlakis (31 commits)")

---

Tags

hacktoberfestmiddlewarephprequestslim3middlewarecliframeworkslim

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/pavlakis-slim-cli/health.svg)

```
[![Health](https://phpackages.com/badges/pavlakis-slim-cli/health.svg)](https://phpackages.com/packages/pavlakis-slim-cli)
```

###  Alternatives

[slim/csrf

Slim Framework 4 CSRF protection PSR-15 middleware

3512.1M94](/packages/slim-csrf)[slim/http-cache

Slim Framework HTTP cache middleware and service provider

1242.9M27](/packages/slim-http-cache)[davidepastore/slim-validation

A slim middleware for validation based on Respect/Validation

171223.7k3](/packages/davidepastore-slim-validation)[davidepastore/slim-restrict-route

A Slim middleware to restrict ip addresses that will access to your routes

2220.6k1](/packages/davidepastore-slim-restrict-route)[davidepastore/slim-config

A slim middleware to read configuration from different files based on hassankhan/config

338.9k1](/packages/davidepastore-slim-config)[geggleto/psr7-recaptcha

113.2k](/packages/geggleto-psr7-recaptcha)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
