Cheat Sheets & Quick References

PHP CLI Commands Cheat Sheet

Useful PHP command-line commands for checking runtime configuration, linting files and running scripts.

Overview

The PHP command-line interface is useful for maintenance scripts, scheduled jobs, development checks and deployment workflows.

Common commands

  • php -v displays the CLI PHP version.
  • php -m lists loaded extensions.
  • php --ini shows configuration file locations.
  • php -l file.php checks PHP syntax without executing the script.
  • php script.php runs a PHP script.
  • php -S 127.0.0.1:8000 starts the built-in development server.
  • php --ri pdo_mysql displays information about an extension.

Environment awareness

The CLI binary and web server may use different PHP versions or configuration files. Verify both environments when diagnosing hosting issues. Do not expose the built-in development server directly to the public internet.

Official resource

PHP Command Line Usage