(Translated by https://www.hiragana.jp/)
GitHub - EekoS/php-fpm-cli: With this simple script, one can execute PHP scripts directly from CLI.
Skip to content

With this simple script, one can execute PHP scripts directly from CLI.

License

Notifications You must be signed in to change notification settings

EekoS/php-fpm-cli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 

Repository files navigation

php-fpm-cli

Running PHP-FPM, especially for website hosts using NGINX, is missing an important functionality to execute PHP scripts directly from the command-line.

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.

This script is based on Mathias Leppich's gist, 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.

See more details in: https://elisegev.medium.com/running-php-fpm-in-cli-e1f0f4b4f59a

Requirements

Dependencies

RHEL / CentOS

yum --enablerepo=epel install fcgi

Ubuntu / Debian

apt-get install libfcgi0ldbl

Setup

PHP script needs to be executable and owned by an allowed user (ACL):

vi /etc/php-fpm.d/www.conf
# add your ACL user to the comma-delimited list: listen.acl_users
# e.g. listen.acl_users = apache,nginx,myuser
systemctl restart php-fpm

Usage

Run PHP script:

./php-fqm-cli -f <path_to_php_file>

Run PHP script with query params:

./php-fqm-cli -f <path_to_php_file> -q "<query_params>"

Example:

./php-fqm-cli -f myscript.php -q "param1=val1&param2=val2"

About

With this simple script, one can execute PHP scripts directly from CLI.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages