PHP Command-line interpreter
Light · Postcard
102 × 152 mm · PDF
Dark · Postcard
102 × 152 mm · PDF
Ink saver · Postcard
102 × 152 mm · PDF
Light · A4 landscape
297 × 210 mm · PDF
Dark · A4 landscape
297 × 210 mm · PDF
Ink saver · A4 landscape
297 × 210 mm · PDF
Light · A3 landscape
420 × 297 mm · PDF
Dark · A3 landscape
420 × 297 mm · PDF
Ink saver · A3 landscape
420 × 297 mm · PDF
Start here
php <file>
php -r '<code>'
php -l <file>
php -S localhost:8000
php -aphp -vphp -mphp --iniConcepts
- php.ini main config
- conf.d/*.ini per extension
- -d key=value this run only
Run code
php <file> [args]
php -r '<code>'
php -r '<code>' -- -x
php -f <file>
php < <file>
php -d <key>=<value> <file>
php -d memory_limit=-1 <file>
php -c <path> <file>
php -n <file>
php -w <file>
php -s <file>
Check and inspect
php -l <file>
php -vphp -mphp -iphp --iniphp --ini=diffphp --ri <ext>
php --ri mainphp -hBuilt-in server
php -S localhost:8000
php -S localhost:8000 -t <dir>
php -S 0.0.0.0:8000
php -S localhost:8000 <router.php>
PHP_CLI_SERVER_WORKERS=4 php -S localhost:8000
Configuration
display_errors=1
error_reporting=E_ALL
memory_limit=512M
max_execution_time=0
date.timezone=UTC
opcache.enable_cli=1
php -d <key>=<value> --ri <ext>
Reflection
php --rf <function>
php --rc <class>
php --re <ext>
php --rz <zend-ext>
Process input lines
php -R '<code>'
php -B '<code>' -R '<code>' -E
'<code>'
php -F <file>
Interactive
php -a#cli.pager=less#cli.prompt=<text>
Recipes
find src -name '*.php' -print0 | xargs -0 -n1 php -l
php -r 'echo PHP_VERSION, PHP_EOL;'php -r 'echo json_encode(array_slice(get_loaded_extensions(), 0, 3));'echo 'a b' | php -R 'echo strtoupper($argn), PHP_EOL;'
php -S localhost:8000 -t public public/index.php# open http://localhost:8000
php -m | grep -i <ext>php --iniphp --ri <ext>



