PHPackages                             forrest79/phpfpm-request - 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. [CLI &amp; Console](/categories/cli)
4. /
5. forrest79/phpfpm-request

ActiveLibrary[CLI &amp; Console](/categories/cli)

forrest79/phpfpm-request
========================

Run php-fpm requests from command line.

v0.9.0(8mo ago)11.4kBSD-3-ClausePHPPHP ^8.3CI passing

Since Nov 16Pushed 7mo ago1 watchersCompare

[ Source](https://github.com/forrest79/phpfpm-request)[ Packagist](https://packagist.org/packages/forrest79/phpfpm-request)[ RSS](/packages/forrest79-phpfpm-request/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (5)Versions (19)Used By (0)

PhpFpmRequest
=============

[](#phpfpmrequest)

[![Latest Stable Version](https://camo.githubusercontent.com/a413d0c0303136c73e7eb9c1c6d77348f0d5d2acbce7a287c287b630c2cc530a/68747470733a2f2f706f7365722e707567782e6f72672f666f727265737437392f70687066706d2d726571756573742f76)](//packagist.org/packages/forrest79/phpfpm-request)[![Monthly Downloads](https://camo.githubusercontent.com/a769aae20b0cec7632153784039779b449b23616574ad0044679742191df83d9/68747470733a2f2f706f7365722e707567782e6f72672f666f727265737437392f70687066706d2d726571756573742f642f6d6f6e74686c79)](//packagist.org/packages/forrest79/phpfpm-request)[![License](https://camo.githubusercontent.com/f218f8529a189ee7ddd7b030840c52c34c71ebc6224af92fdf5df28af233ea30/68747470733a2f2f706f7365722e707567782e6f72672f666f727265737437392f70687066706d2d726571756573742f6c6963656e7365)](//packagist.org/packages/forrest79/phpfpm-request)[![Build](https://github.com/forrest79/phpfpm-request/actions/workflows/build.yml/badge.svg?branch=master)](https://github.com/forrest79/phpfpm-request/actions/workflows/build.yml)

Simply utility to make `php-fpm` requests right from command line with no needs to set up your web server for these requests.

Installation
------------

[](#installation)

The recommended way to install Forrest79/PhpFpmRequest is through Composer:

```
composer require forrest79/phpfpm-request
```

This also needs `cgi-fcgi` installed on your system. On Debian (Ubuntu...) like linux, you can do this:

```
sudo apt install libfcgi0ldbl
```

You can you this to clear some caches from cli that need to be called via HTTP request (opcache, apcu, ...) or to warm up your cache after a new version is deployed and before web server is started to point to new source code.

How to use it
-------------

[](#how-to-use-it)

We just need to know, where is `php-fpm` listening. It's config directive `listen` and it could be `socket` or `TCP\IP`. In `nginx` it's directive `fastcgi_pass`. If you don't know that, or you're planning to run this on different systems, you can try to autodetect this:

```
$requester = Forrest79\PhpFpmRequest\Requester::autodetect();
```

Or if you know where `php-fpm` is listening, you can use this value:

```
$requester = Forrest79\PhpFpmRequest\Requester::create('/var/run/php/php7.4-fpm.sock');
```

Now just simple set PHP file to process with `php-fpm`:

```
$requester->setPhpFile('/var/www/index.php');
```

And send the request:

```
$response = $requester->send();
```

Now we have `Response` object, that can return `array` of `HTTP` headers and text body.

```
echo $reponse->getBody() . PHP_EOL;

foreach ($response->getHeaders() as $header) {
    echo $header . PHP_EOL;
}
```

If you need to pass more options to `php-fpm`, just use `setOption(string $name, string $value)` method. Only `REQUEST_METHOD` is set automatically to `GET` and `SCRIPT_FILENAME` is pass. But you can add anything you want:

```
$requester
    ->setOption('QUERY_STRING', '?param=1')
    ->setOption('SERVER_NAME', 'my-server.com')
    ->setOption('REQUEST_URI', '/show-detail/');
```

If you need better API for this, extends `Requester` with your own class and create better public API and in every method just call `parent::setOption('...', '...')`.

### Cli and php-fpm in one file

[](#cli-and-php-fpm-in-one-file)

You can have `cli` and `php-fpm` source code in one file:

```
if (PHP_SAPI === 'cli') {
    echo Forrest79\PhpFpmRequest\Requester::autodetect()
        ->setPhpFile(__FILE__)
        ->send()
        ->getBody() . PHP_EOL;
} else {
    echo 'This code is processed with php-fpm. You can warm up your cache here, clean cache, etc.';
}
```

###  Health Score

45

—

FairBetter than 93% of packages

Maintenance62

Regular maintenance activity

Popularity20

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity75

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 ~146 days

Recently: every ~289 days

Total

18

Last Release

245d ago

PHP version history (5 changes)v0.1.0PHP &gt;=7.1

v0.5.0PHP &gt;=7.4

v0.6.0PHP ^7.4 | ^8.0

v0.8.0PHP ^8.0

v0.9.0PHP ^8.3

### Community

Maintainers

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

---

Top Contributors

[![forrest79](https://avatars.githubusercontent.com/u/160766?v=4)](https://github.com/forrest79 "forrest79 (45 commits)")

---

Tags

requestcliphpfpm

###  Code Quality

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/forrest79-phpfpm-request/health.svg)

```
[![Health](https://phpackages.com/badges/forrest79-phpfpm-request/health.svg)](https://phpackages.com/packages/forrest79-phpfpm-request)
```

###  Alternatives

[symfony/console

Eases the creation of beautiful and testable command line interfaces

9.8k1.1B11.3k](/packages/symfony-console)[nunomaduro/collision

Cli error handling for console/command-line PHP applications.

4.6k331.8M8.5k](/packages/nunomaduro-collision)[nunomaduro/termwind

It's like Tailwind CSS, but for the console.

2.5k239.8M286](/packages/nunomaduro-termwind)[wp-cli/wp-cli

WP-CLI framework

5.0k17.2M320](/packages/wp-cli-wp-cli)[wp-cli/php-cli-tools

Console utilities for PHP

68325.0M367](/packages/wp-cli-php-cli-tools)[socialengine/sniffer-rules

A Lumen 5 and Laravel 5 SquizLabs Code Sniffer 2.0 artisan command. Detect violations of a defined coding standard. It helps your code remains clean and consistent.

1248.2k1](/packages/socialengine-sniffer-rules)

PHPackages © 2026

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