You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+25-11Lines changed: 25 additions & 11 deletions
Original file line number
Diff line number
Diff line change
@@ -1,12 +1,16 @@
1
1
# php-fpm-cli
2
2
3
-
Running PHP-FPM, especially for website hosts using NGINX, is missing an important functionality to execute PHP scripts directly from the command-line.
3
+
Running PHP-FPM, especially for website hosts using NGINX, is missing the important ability to execute PHP scripts directly from the command-line while simulating the website context.
4
4
5
-
With this simple script, one can execute PHP scripts directly from CLI. It is convenient to test PHP in CLI, run batch operations with PHP and for cronjobs.
5
+
With this simple script, one can execute PHP scripts that are normally called via PHP-FPM, directly from CLI. This can be used for testing, batch operations, or cronjobs.
6
6
7
-
This script is based on [Mathias Leppich's gist][1], with added support for loading the script from a file (instead of input code as CLI argument), query-string parameters and verification of not only the exit code of the script - but also http-status-code.
7
+
This script is based on [Mathias Leppich's gist][1], with added support for:
8
+
* loading the script from a file (instead of input code as CLI argument)
9
+
* query-string parameters
10
+
* verification of not only the exit code of the script, but also http-status-code.
11
+
* guessing of `$_SERVER` variables given a URL to simulate
8
12
9
-
See more details in: https://elisegev.medium.com/running-php-fpm-in-cli-e1f0f4b4f59a
13
+
See more details in[this Medium post](https://elisegev.medium.com/running-php-fpm-in-cli-e1f0f4b4f59a).
10
14
11
15
## Requirements
12
16
@@ -24,7 +28,7 @@ apt-get install libfcgi0ldbl
24
28
25
29
### Setup
26
30
27
-
PHP script needs to be executable and owned by an allowed user (ACL):
31
+
The PHP script being executed needs to be executable and owned by an user allowed by the PHP-FPM configuration, so you may need to update it:
28
32
```shell script
29
33
vi /etc/php-fpm.d/www.conf
30
34
# add your ACL user to the comma-delimited list: listen.acl_users
@@ -34,19 +38,29 @@ systemctl restart php-fpm
34
38
35
39
## Usage
36
40
37
-
Run PHP script:
41
+
The script will send the given PHP file to the PHP-FPM process and echo the response to STDOUT.
|`-f`| Path to the PHP file ||`/var/www/html/index.php`|
51
+
|`-connect`| PHP-FPM host and port, or path to a socket |`/run/php-fpm/www.sock`|`127.0.0.1:9000`|
52
+
|`-m`| Request method, GET or POST | GET ||
53
+
|`-u`| URL to simulate. This must return an status code 200, so make sure this is the canonical URL (i.e., it will not redirect) ||`https://www.mydomain.com/`|
0 commit comments