PHP supports different Server Application Programming Interfaces (SAPI) for environment interaction and connection to non-native technologies. Two of them are PHP CLI and PHP CGI (FastCGI).
As of v. 4.3.0, PHP supports an additional interface called CLI (Command Line Interface) intended to be used in a shell environment.
PHP CLI is used for developing applications in PHP that can be automated with Cron jobs, for administration, testing and other tasks, suitable for shell usage. PHP CLI runs directly in server environment without requesting connection to the web server from the CGI (FastCGI) interface.
PHP CLI differs from other interfaces mainly because of the following reasons:
- It does not return HTTP headers; it starts with a -q (quiet-mode) option by default, which suppresses HTTP header output (stdout);
- It does not change its current directory to the directory of the executed script;
- It uses only plain text error messages. The php.ini directive is set in the following way: html_errors: FALSE. This is due to the fact that reading error messages with HTML tags is quite complicated while working in a shell environment. Hence, HTML formatting has been disabled;
- Some php.ini directives are overridden for PHP CLI because they do not make sense in shell environments.
- max_execution_time: 0 (unlimited) does not hold restrictions for script execution time;
- max_input_time: FALSE – PHP CLI does not support GET, POST or uploading files;
PHP is configured and installed on the server with two separate executable / binary files for CLI and CGI (FastCGI).
|For all PHP versions:|
|ea-phpXX – replace with the PHP version,|
for example /opt/cpanel/ea-php72/root/usr/bin/php
PHP settings for the two interfaces differ: