PHP Cheatsheet - PHP & Composer Command Reference
This reference is for developers writing PHP apps and the people who deploy and operate them, running everything from single scripts to Laravel projects. It covers executing code on the CLI, the built-in dev server, Composer dependency and autoload management, extension/ini checks, and the php -l lint gate. Unlike a generic PHP command dump, entries are grouped by the workflow you actually repeat when scaffolding, debugging, and shipping a PHP application. After reading, you should be able to boot a Composer-based project locally, keep its autoload in sync, and gate merges on a lint pass.
CLI Run 8
php script.phpphp -aphp -S localhost:8000php -S localhost:8000 -t public/php -l script.phpphp -r "echo phpinfo();"php -iphp -mComposer Dependency 10
composer initcomposer installcomposer updatecomposer require vendor/packagecomposer remove vendor/packagecomposer dump-autoloadcomposer dump-autoload -ocomposer showcomposer outdatedcomposer self-updateExtensions & Config 6
php --iniphp -d memory_limit=256M script.phpphp -d display_errors=1 script.phppecl install extensionpecl uninstall extensionphp -r "echo PHP_VERSION;"Laravel Commands 8
php artisan servephp artisan migratephp artisan migrate:freshphp artisan make:model Post -mcrphp artisan route:listphp artisan config:cachephp artisan queue:workphp artisan tinkerProfiling 4
php -d xdebug.mode=profile script.phpphp -d opcache.enable_cli=1 script.phpstrace -p <pid>php -r "echo memory_get_peak_usage();"Tips
- In production always run composer dump-autoload -o to optimize performance.
- php -S is for development only; use Nginx + PHP-FPM in production.
- In Laravel production, cache config, routes and views: config:cache, route:cache, view:cache.
Official References
Each command links to its official documentation below, so you can verify the latest usage and read deeper.
Maintained by LaoHand
Publicly updated on Jul 21, 2026, continuously proofread against official docs.
Contact Us
Wrong command or description? Send us corrections, business inquiries or product feedback by email.
Contact Us