An open API service indexing awesome lists of open source software.

https://github.com/alexanderomara/php-fpm-cli

Run PHP scripts through FastCGI from the command line
https://github.com/alexanderomara/php-fpm-cli

fastcgi php php-cli php-fpm

Last synced: 4 months ago
JSON representation

Run PHP scripts through FastCGI from the command line

Awesome Lists containing this project

README

          

# php-fpm-cli

Run PHP scripts through FastCGI from the command line

[![Build Status](https://github.com/AlexanderOMara/php-fpm-cli/workflows/main/badge.svg)](https://github.com/AlexanderOMara/php-fpm-cli/actions?query=workflow%3Amain+branch%3Amaster)

# Overview

A PHP CLI script to run PHP scripts through a php-fpm worker that is also a pure-PHP FastCGI request CLI.

# Usage

```
Usage: php-fpm-cli -c [options] [script]

-c, --connect Connect to file or host:port
-p, --param = FCGI request = param
-b, --body FCGI request STDIN
-d, --data FCGI request STDIN body from
-i, --include FCGI response headers included in output
-t, --timeout Connect timeout in milliseconds
-h, --help Display help and exit
-v, --version Display version and exit
```

# Examples

## Clear opcache

The cache used by fpm workers and the CLI is separate, so we need to run it inside a php-fpm worker.

```php

string(3) "bar"
["baz"]=>
string(3) "qux"
}
```

## POST request

A request body can be added which PHP will automatically parse with the correct content type.

```php

string(3) "bar"
["baz"]=>
string(3) "qux"
}
```

## PUT request

The default `REQUEST_METHOD` can be overridden.

```php