PHP CLI

Open Source

by PHP.net

Provided by PHP.net

Not yet rated
Platform
Windows / Linux / macOS
Pricing
Open Source
Account required
No
Ads
None
Last verified
11 hours ago
Developer
PHP.net
Official URL

Overview

PHP CLI is the command-line version of the PHP interpreter. PHP is usually thought of as something a web server runs, but the same language can be run straight from a terminal with the php command, which makes it useful for shell scripts, scheduled jobs, build steps and quick experiments. The official URL here is the manual chapter that documents it.

The manual describes it as one of PHP's server interfaces (SAPIs), built by default, and aimed at writing shell applications. It behaves a little differently from PHP under a web server: it sends no HTTP headers, error messages are plain text instead of HTML, output appears immediately, and there is no execution time limit because command-line jobs often run for a long time. Script arguments arrive in the argc and argv variables, and constants are defined for standard input, output and error. Unlike the CGI version, it does not change the working directory to the script's folder.

The chapter also covers the command-line options, an interactive shell for trying code line by line, and a built-in web server meant for local development. On Windows the program is php.exe, with a php-win.exe variant that runs without a console window. PHP itself is open source and free.

Features

  • Runs PHP scripts directly from a terminal or scheduled job
  • Interactive shell for trying code line by line
  • Built-in web server for local development
  • Script arguments available through argc and argv
  • Constants for standard input, output and error streams
  • No execution time limit by default
  • Plain-text error messages and unbuffered output
  • php-win.exe variant on Windows runs without a console window

Privacy

See the official privacy policy. PHP CLI is a program that runs on your own machine.

Pros & Cons

Pros

  • Part of the standard PHP build, so nothing extra to install
  • Same language and libraries as PHP on a web server
  • Built-in server and interactive shell cover quick local testing
  • Free and open source, with full documentation in the PHP manual

Cons

  • Some settings are fixed and cannot be changed from php.ini
  • Working directory and other behaviour differ from web PHP, which can surprise scripts moved between the two
  • The built-in web server is intended for development, not for public sites
  • No GET, POST or upload handling when run from the command line

Community Reviews (0)

No written reviews yet — be the first to rate this tool.

Similar Tools

  • Interpreters · Python

    Runs Python programs and scripts.

    Not yet rated
    Open Source Android iOS
  • Interpreters · Ruby

    Runs Ruby programs and scripts.

    Not yet rated
    Open Source Windows Linux