Command Line Interface (CLI)

PHP provides support for a Command Line Interface (CLI) mode, which allows developers to execute PHP scripts directly from the terminal or command prompt without needing a web server. In this mode, commands are passed as a file or lines of text, and the PHP interpreter processes them sequentially. This feature is particularly useful for automation tasks, cron jobs, scripting, testing, or running PHP-based tools. Additionally, the CLI mode offers access to command-line arguments, making it possible to write interactive scripts or utilities that can process user input or parameters at runtime.

Documentation

See also Detailed Guide on PHP Command Line (CLI) and Essential Commands for PHP Developers.

Related : Webserver, Server Application Programming Interface (SAPI), Read Eval Print Loop (REPL), $argc, $argv, Common Gateway Interface (CGI), FastCGI, Application, Desktop Application, Tool, Terminal User Interface (TUI), Command, pcntl_signal()

Related packages : splitbrain/php-cli