<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Introduction</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="features.commandline.html">Command line usage</a></div> <div class="next" style="text-align: right; float: right;"><a href="features.commandline.differences.html">Differences to other SAPIs</a></div> <div class="up"><a href="features.commandline.html">Command line usage</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div><hr /><div id="features.commandline.introduction" class="section"> <h2 class="title">Introduction</h2> <p class="para"> PHP supports a <acronym title="Command Line Interpreter/Interface">CLI</acronym> <acronym title="Server Application Programming Interface">SAPI</acronym> as of PHP 4.3.0. The main focus of this <acronym title="Server Application Programming Interface">SAPI</acronym> is for developing shell applications with PHP. There are quite a few differences between the <acronym title="Command Line Interpreter/Interface">CLI</acronym> <acronym title="Server Application Programming Interface">SAPI</acronym> and other <acronym title="Server Application Programming Interface">SAPI</acronym>s which are explained in this chapter. It is worth mentioning that <acronym title="Command Line Interpreter/Interface">CLI</acronym> and <acronym title="Common Gateway Interface">CGI</acronym> are different <acronym title="Server Application Programming Interface">SAPI</acronym>s although they do share many of the same behaviors. </p> <p class="para"> The <acronym title="Command Line Interpreter/Interface">CLI</acronym> <acronym title="Server Application Programming Interface">SAPI</acronym> is enabled by default using <strong class="option configure">--enable-cli</strong> , but may be disabled using the <strong class="option configure">--disable-cli</strong> option when running <strong class="command">./configure</strong>. </p> <p class="para"> The name, location and existence of the <acronym title="Command Line Interpreter/Interface">CLI</acronym>/<acronym title="Common Gateway Interface">CGI</acronym> binaries will differ depending on how PHP is installed on your system. By default when executing <strong class="command">make</strong>, both the <acronym title="Common Gateway Interface">CGI</acronym> and <acronym title="Command Line Interpreter/Interface">CLI</acronym> are built and placed as <var class="filename">sapi/cgi/php-cgi</var> and <var class="filename">sapi/cli/php</var> respectively, in your PHP source directory. You will note that both are named <var class="filename">php</var>. What happens during <strong class="command">make install</strong> depends on your configure line. If a module <acronym title="Server Application Programming Interface">SAPI</acronym> is chosen during configure, such as apxs, or the <strong class="option configure">--disable-cgi</strong> option is used, the <acronym title="Command Line Interpreter/Interface">CLI</acronym> is copied to <var class="filename">{PREFIX}/bin/php</var> during <strong class="command">make install</strong> otherwise the <acronym title="Common Gateway Interface">CGI</acronym> is placed there. So, for example, if <strong class="option configure">--with-apxs </strong> is in your configure line then the <acronym title="Command Line Interpreter/Interface">CLI</acronym> is copied to <var class="filename">{PREFIX}/bin/php </var> during <strong class="command">make install</strong>. If you want to override the installation of the <acronym title="Common Gateway Interface">CGI</acronym> binary, use <strong class="command">make install-cli</strong> after <strong class="command">make install</strong>. Alternatively you can specify <strong class="option configure">--disable-cgi</strong> in your configure line. </p> <blockquote class="note"><p><strong class="note">Note</strong>: <p class="para"> Because both <strong class="option configure">--enable-cli</strong> and <strong class="option configure">--enable-cgi</strong> are enabled by default, simply having <strong class="option configure">--enable-cli</strong> in your configure line does not necessarily mean the <acronym title="Command Line Interpreter/Interface">CLI</acronym> will be copied as <var class="filename">{PREFIX}/bin/php</var> during <strong class="command">make install</strong>. </p> </p></blockquote> <p class="para"> As of PHP 5, the <acronym title="Command Line Interpreter/Interface">CLI</acronym> binary is distributed in the main folder as <var class="filename"> php.exe</var> on Windows. The <acronym title="Common Gateway Interface">CGI</acronym> version is distributed as <var class="filename">php-cgi.exe</var>. Additionally, a <var class="filename"> php-win.exe</var> is distributed if PHP is configured using <strong class="option configure">--enable-cli-win32</strong> . This does the same as the <acronym title="Command Line Interpreter/Interface">CLI</acronym> version, except that it doesn't output anything and thus provides no console. </p> <blockquote class="note"><p><strong class="note">Note</strong>: <strong>What SAPI do I have?</strong><br /> <p class="para"> From a shell, typing <strong class="command">php -v</strong> will tell you whether <var class="filename">php</var> is <acronym title="Common Gateway Interface">CGI</acronym> or <acronym title="Command Line Interpreter/Interface">CLI</acronym>. See also the function <span class="function"><a href="function.php-sapi-name.html" class="function">php_sapi_name()</a></span> and the constant <strong><code>PHP_SAPI</code></strong>. </p> </p></blockquote> <blockquote class="note"><p><strong class="note">Note</strong>: <p class="para"> A Unix <em>man</em>ual page is available by typing <strong class="command">man php</strong> in the shell environment. </p> </p></blockquote> </div><hr /><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="features.commandline.html">Command line usage</a></div> <div class="next" style="text-align: right; float: right;"><a href="features.commandline.differences.html">Differences to other SAPIs</a></div> <div class="up"><a href="features.commandline.html">Command line usage</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div></body></html>