Here’s a cheat sheet for the most common Laravel Artisan commands:

General Commands:

php artisan list # List all available Artisan commands
php artisan help [command] # Get help for a specific command
php artisan tinker # Open a REPL (interactive shell) for Laravel
php artisan serve # Start the local development server
php artisan down # Put the application into maintenance mode
php artisan up # Bring the application out of maintenance mode
php artisan migrate # Run all outstanding migrations

Make Commands (Generating Classes, Controllers, Models, etc.):

php artisan make:controller MyController # Create a controller
php artisan make:model MyModel # Create a model
php artisan make:migration create_my_table # Create a migration file
php artisan make:seeder MySeeder # Create a seeder file
php artisan make:factory MyFactory # Create a factory
php artisan make:middleware MyMiddleware # Create middleware
php artisan make:request MyRequest # Create a form request class
php artisan make:job MyJob # Create a job
php artisan make:event MyEvent # Create an event
php artisan make:listener MyListener # Create a listener
php artisan make:command MyCommand # Create a custom Artisan command
php artisan make:policy MyPolicy # Create a policy class
php artisan make:resource MyResource # Create an API resource class
php artisan make:rule MyRule # Create a custom validation rule
php artisan make:test MyTest # Create a test class

Migration Commands:

php artisan migrate # Run all pending migrations
php artisan migrate:rollback # Rollback the last migration operation
php artisan migrate:reset # Rollback all migrations
php artisan migrate:refresh # Rollback all and rerun migrations
php artisan migrate:status # Check the status of each migration
php artisan migrate:fresh # Drop all tables and rerun all migrations

Seeder and Database Commands:

php artisan db:seed # Run the database seeders
php artisan db:wipe # Drop all tables, views, and types
php artisan migrate:refresh --seed # Refresh migrations and seed database

Cache & Config Commands:

php artisan cache:clear # Clear the application cache
php artisan config:clear # Clear the configuration cache
php artisan config:cache # Cache the configuration files
php artisan route:cache # Cache the routes
php artisan route:clear # Clear the route cache
php artisan view:clear # Clear all compiled view files
php artisan optimize # Optimize the application (autoload cache)

Route Commands:

php artisan route:list # List all registered routes

Queue Commands:

php artisan queue:work # Start processing jobs on the queue
php artisan queue:restart # Restart queue worker daemons
php artisan queue:table # Create a migration for the jobs database table
php artisan queue:flush # Flush all failed queue jobs

Event & Listener Commands:

php artisan event:generate # Generate event and listener stubs

Storage Commands:

php artisan storage:link # Create a symbolic link to the storage folder

Testing:

php artisan test # Run the application tests
php artisan test --filter=ClassName # Run a specific test

This cheat sheet covers most of the commonly used Artisan commands in Laravel.

Share!

Shares