<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/features.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'fr',
  ),
  'this' => 
  array (
    0 => 'features.commandline.php',
    1 => 'Utilisation des lignes de commande',
    2 => 'Utiliser PHP en ligne de commande',
  ),
  'up' => 
  array (
    0 => 'features.php',
    1 => 'Caract&eacute;ristiques',
  ),
  'prev' => 
  array (
    0 => 'features.persistent-connections.php',
    1 => 'Connexions persistantes aux bases de donn&eacute;es',
  ),
  'next' => 
  array (
    0 => 'features.commandline.differences.php',
    1 => 'Diff&eacute;rences avec les autres SAPIs',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'fr',
    'path' => 'features/commandline.xml',
  ),
  'history' => 
  array (
  ),
  'extra_header_links' => 
  array (
    'rel' => 'alternate',
    'href' => '/manual/en/feeds/features.commandline.atom',
    'type' => 'application/atom+xml',
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="features.commandline" class="chapter">
 <h1 class="title">Utiliser PHP en ligne de commande</h1>
<h2>Sommaire</h2><ul class="chunklist chunklist_chapter"><li><a href="features.commandline.differences.php">Diff&eacute;rences avec les autres SAPIs</a></li><li><a href="features.commandline.options.php">Options</a></li><li><a href="features.commandline.usage.php">Utilisation</a></li><li><a href="features.commandline.io-streams.php">Flux I/O</a></li><li><a href="features.commandline.interactive.php">Shell Interactif</a></li><li><a href="features.commandline.webserver.php">Serveur web interne</a></li><li><a href="features.commandline.ini.php">Configurations INI</a></li></ul>

 
 
 
 <div id="features.commandline.introduction" class="section">
  <h2 class="title">Introduction</h2>
  
  <p class="para">
   Le but premier de <abbr title="Command Line Interpreter/Interface">CLI</abbr> <abbr title="Server Application Programming Interface">SAPI</abbr> est le développement
   d&#039;applications shell avec PHP. Les différences entre le <abbr title="Command Line Interpreter/Interface">CLI</abbr> <abbr title="Server Application Programming Interface">SAPI</abbr>
   et les autres <abbr title="Server Application Programming Interface">SAPI</abbr> sont
   expliquées dans ce chapitre. Il est important de mentionner que <abbr title="Command Line Interpreter/Interface">CLI</abbr>
   et <abbr title="Common Gateway Interface">CGI</abbr> sont des <abbr title="Server Application Programming Interface">SAPI</abbr> différents malgré
   le fait qu&#039;ils puissent partager la majeure partie de leurs comportements.
  </p>
  
  <p class="para">
   Le <abbr title="Command Line Interpreter/Interface">CLI</abbr> <abbr title="Server Application Programming Interface">SAPI</abbr> est activé par défaut en utilisant l&#039;option
   <strong class="option configure">--enable-cli</strong>, mais il est possible de le désactiver
   en utilisant l&#039;option <strong class="option configure">--disable-cli</strong>
   lors de l&#039;exécution de la commande <strong class="command">./configure</strong>.
  </p>
  
  <p class="para">
   Le nom, l&#039;emplacement et l&#039;existence des binaires <abbr title="Command Line Interpreter/Interface">CLI</abbr>/<abbr title="Common Gateway Interface">CGI</abbr>
   vont dépendre de la façon dont PHP est installé sur le système. Par
   défaut, en exécutant <strong class="command">make</strong>, les deux binaires <abbr title="Common Gateway Interface">CGI</abbr>
   et <abbr title="Command Line Interpreter/Interface">CLI</abbr> sont compilés et nommés respectivement <var class="filename">sapi/cgi/php-cgi</var> et
   <var class="filename">sapi/cli/php</var> dans le répertoire source PHP. On
   remarquera que les deux se nomment <var class="filename">php</var>. Ce qui se passe
   ensuite pendant le <strong class="command">make install</strong> dépend de la ligne
   de configuration. Si un module <abbr title="Server Application Programming Interface">SAPI</abbr>, apxs par exemple, a été choisi pendant la
   configuration, ou que l&#039;option <strong class="option configure">--disable-cgi</strong> a été
   activée, le <abbr title="Command Line Interpreter/Interface">CLI</abbr> est copié dans <var class="filename">{PREFIX}/bin/php</var> pendant
   le <strong class="command">make install</strong> sinon, le <abbr title="Common Gateway Interface">CGI</abbr> sera placé ici.
   Si, par exemple, <strong class="option configure">--with-apxs</strong> figure dans la
   ligne de configuration, le <abbr title="Command Line Interpreter/Interface">CLI</abbr> est copié dans <var class="filename">{PREFIX}/bin/php</var>
   pendant le <strong class="command">make install</strong>. Pour forcer l&#039;installation du
   binaire <abbr title="Common Gateway Interface">CGI</abbr>, lancez <strong class="command">make install-cli</strong>
   après le <strong class="command">make install</strong>. Sinon, il est aussi possible de spécifier
   <strong class="option configure">--disable-cgi</strong> dans la ligne de configuration.
  </p>
  
  <blockquote class="note"><p><strong class="note">Note</strong>: 
   <p class="para">
    Du fait que les deux options <strong class="option configure">--enable-cli</strong> et
    <strong class="option configure">--enable-cgi</strong> sont activées par défaut, avoir simplement
    <strong class="option configure">--enable-cli</strong> dans la ligne de configuration
    n&#039;implique pas nécessairement que le CLI soit renommé en <var class="filename">
    {PREFIX}/bin/php</var> pendant le <strong class="command">make install</strong>.
   </p>
  </p></blockquote>
  
  <p class="para">
   Le binaire <abbr title="Command Line Interpreter/Interface">CLI</abbr> est distribué dans le dossier principal
   sous le nom de <var class="filename">php.exe</var> sous Windows. La version
   <abbr title="Common Gateway Interface">CGI</abbr> est distribuée sous le nom de <var class="filename">php-cgi.exe</var>.
   De plus, un fichier <var class="filename">php-win.exe</var> est distribué si PHP
   est configuré en utilisant l&#039;option de configuration
   <strong class="option configure">--enable-cli-win32</strong>. Ce fichier fait la
   même chose que la version <abbr title="Command Line Interpreter/Interface">CLI</abbr>, sauf qu&#039;il n&#039;affiche rien et qu&#039;il ne fournit
   pas de console.
  </p>
  
  <blockquote class="note"><p><strong class="note">Note</strong>: 
   <strong>Quel SAPI est installé ?</strong><br />
   <p class="para">
    À partir d&#039;un terminal, lancer <strong class="command">php -v</strong> indiquera si
    <var class="filename">php</var> est en version <abbr title="Common Gateway Interface">CGI</abbr> ou
    <abbr title="Command Line Interpreter/Interface">CLI</abbr>. Il est aussi possible de consulter la fonction
    <span class="function"><a href="function.php-sapi-name.php" class="function">php_sapi_name()</a></span> et la constante
    <strong><code><a href="reserved.constants.php#constant.php-sapi">PHP_SAPI</a></code></strong>.
   </p>
  </p></blockquote>
  <blockquote class="note"><p><strong class="note">Note</strong>: 
   <p class="para">
    Une page <code class="literal">man</code> de manuel Unix est disponible
    en tapant <strong class="command">man php</strong> dans l&#039;interpréteur de commande.
   </p>
  </p></blockquote>
 </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
</div>
<?php manual_footer($setup); ?>