Chapter 23. Using PHP from the command
line
As of version 4.3.0, PHP supports a new SAPI type (Server
Application Programming Interface) named CLI which means Command
Line Interface. As the name implies, this SAPI type main focus
is on developing shell (or desktop as well) applications with
PHP. There are quite a few differences between the CLI SAPI
and other SAPIs which are explained in this chapter. It's
worth mentioning that CLI and CGI are different SAPI's although
they do share many of the same behaviors.
The CLI SAPI was released for the first time with PHP 4.2.0,
but was still experimental and had to be explicitly enabled
with --enable-cli when running ./configure. Since PHP 4.3.0
the CLI SAPI is no longer experimental and the option --enable-cli
is on by default. You may use --disable-cli to disable it.
As of PHP 4.3.0, the name, location and existence of the
CLI/CGI binaries will differ depending on how PHP is installed
on your system. By default when executing make, both the
CGI and CLI are built and placed as sapi/cgi/php and sapi/cli/php
respectively, in your PHP source directory. You will note
that both are named php. What happens during make install
depends on your configure line. If a module SAPI is chosen
during configure, such as apxs, or the --disable-cgi option
is used, the CLI is copied to {PREFIX}/bin/php during make
install otherwise the CGI is placed there. So, for example,
if --with--apxs is in your configure line then the CLI is
copied to {PREFIX}/bin/php during make install. If you want
to override the installation of the CGI binary, use make
install-cli after make install. Alternatively you can specify
--disable-cgi in your configure line.
Note: Because both --enable-cli and --enable-cgi are enabled
by default, simply having --enable-cli in your configure
line does not necessarily mean the CLI will be copied as
{PREFIX}/bin/php during make install.
|