• Skip to primary navigation
  • Skip to main content
  • Skip to footer
Jabal Torres Logo
  • About
  • Work
  • Blog
  • Contact Me

Comprehensive PHP CLI Commands

May 9, 2025May 9, 2025 by JabalPosted in WebTags: ComposerLaravelPHP

A curated list of useful PHP CLI commands for day-to-day development, debugging, and project management.


🧰 Basic PHP CLI Commands

Command Description
php -v Show the installed PHP version
php -m List all loaded PHP extensions
php -i Show detailed PHP configuration info (similar to phpinfo())
php --ini Show loaded php.ini file and additional config files
php -a Interactive shell (REPL) to run PHP code live
php -r 'code;' Run inline PHP code without a script file (e.g., php -r 'echo 2+2;')
php -l file.php Lint a PHP file (syntax check only)
php -S localhost:8000 Start PHP’s built-in development server
php -d option=value Override a php.ini directive at runtime (e.g., php -d memory_limit=512M)

📦 Composer (Dependency Manager)

Command Description
composer install Install dependencies from composer.lock
composer update Update dependencies based on composer.json
composer dump-autoload Regenerate optimized autoload files
composer require package/name Add a package to your project
composer remove package/name Remove a package from your project
composer show List installed packages
composer outdated Show which packages have newer versions available
composer validate Check if your composer.json file is valid
composer run-script script-name Run a defined script from composer.json

🚀 Laravel-Specific Artisan Commands

Command Description
php artisan serve Start Laravel’s built-in dev server
php artisan migrate Run database migrations
php artisan db:seed Seed the database with test data
php artisan make:model ModelName Create a new Eloquent model
php artisan make:controller ControllerName Create a controller
php artisan route:list Show all defined routes
php artisan tinker Laravel’s interactive shell (based on PsySH)

🔧 Debugging & System Tools

Command Description
php -r 'print_r(get_loaded_extensions());' List loaded PHP extensions in a script
php -r 'var_dump(ini_get("memory_limit"));' Get a config value dynamically
php -r 'var_dump(opcache_get_status());' Show OPCache status if enabled
php -r 'echo memory_get_usage();' Show current memory usage

🧪 Misc Dev Server Commands

Command Description
php -S localhost:8000 -t public Serve from a specific directory (e.g., public/)
php -S 0.0.0.0:8080 Listen on all network interfaces (good for mobile testing)

Last updated: 2025

  • Share on facebook
  • Share on twitter
  • Share on linkedin

Latest Posts

  • 10 Cron Automations Marketing Developers Should Steal Today
  • When to Stop Building and Start Shipping
  • The Complete Git Command Guide: From Beginner to Advanced
  • Postmark MCP Server
  • Comprehensive PHP CLI Commands
  • KrateCMS: A Developer-Friendly CMS with Laravel 11
  • Managing Multiple .env Files in Laravel for Local, Staging, and Production Environments
Posted in WebTags: ComposerLaravelPHP

Post navigation

Previous: KrateCMS: A Developer-Friendly CMS with Laravel 11
Next: Postmark MCP Server

Copyright © 2026. Jabal Torres. All rights reserved.

  • About
  • Work
  • Blog
  • Contact Me