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
- Host: GitHub
- URL: https://github.com/alexanderomara/php-fpm-cli
- Owner: AlexanderOMara
- License: mpl-2.0
- Created: 2024-07-12T02:37:20.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-07-12T04:54:29.000Z (over 1 year ago)
- Last Synced: 2025-02-01T04:25:58.604Z (about 1 year ago)
- Topics: fastcgi, php, php-cli, php-fpm
- Language: PHP
- Homepage:
- Size: 26.4 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# php-fpm-cli
Run PHP scripts through FastCGI from the command line
[](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