![]() |
Laravel has become a go-to PHP framework for crafting modern web applications. One of the features that really sets it apart is the Artisan CLI (Command Line Interface). This handy tool comes packed with powerful built-in commands that make development tasks a breeze, like handling database migrations, scaffolding code, and running tests. Plus, Laravel allows you to whip up your own custom commands, making it super easy to automate those repetitive tasks.
In this blog, we’re going to dive into the essential Artisan commands that every Laravel developer should be familiar with. Plus, we’ll walk you through a detailed guide on how to create your own custom Artisan commands.
Here is a comprehensive list of the most commonly used Laravel Artisan commands, organized by category:
1. Help & General Commands
1. Lists all available Artisan commands
php artisan list2. Displays help information about a specific command
php artisan help {command}3. Displays Laravel version
php artisan --version2. Make (Code Generation) Commands
1. Runs pending database migrations
php artisan make:controller {ControllerName}2. Creates a new Eloquent model
php artisan make:model {ModelName}3. Creates a model and its migration
php artisan make:model {ModelName} -m4. Creates a new migration file
php artisan make:migration {MigrationName}5. Creates a new database seeder
php artisan make:seeder {SeederName}6. Creates a model factory
php artisan make:factory {FactoryName}7. Creates a new middleware class
php artisan make:middleware {MiddlewareName}8. Creates a custom Artisan command
php artisan make:command {CommandName}9. Creates an authorization policy
php artisan make:policy {PolicyName}10. Creates a form request class
php artisan make:request {RequestName}11. Creates a new event class
php artisan make:event {EventName}12. Creates an event listener class
php artisan make:listener {ListenerName}13. Creates a new job class
php artisan make:job {JobName}14. Creates a new notification class
php artisan make:notification {NotificationName}15. Creates a PHPUnit test class
php artisan make:test {TestName}3. Database Commands
1. Runs pending database migrations
php artisan migrate2. Rolls back the last migration batch
php artisan migrate:rollback3. Rolls back all migrations
php artisan migrate:reset4. Resets and re-runs all migrations
php artisan migrate:refresh5. Drops all tables and runs all migrations afresh
php artisan migrate:fresh6. Runs database seeders
php artisan db:seed7. Runs a specific seeder class
php artisan db:seed --class={SeederClass}8. Displays the status of each migration
php artisan migrate:status4. Cache & Configuration
1. Caches the configuration filesphp artisan config:cachephp artisan config:clearphp artisan cache:clearphp artisan route:cachephp artisan route:clearphp artisan view:clearphp artisan optimize5. Routes
php artisan route:listphp artisan route:clearphp artisan route:cache6. Queue
php artisan queue:workphp artisan queue:listenphp artisan queue:retry {id}php artisan queue:failedphp artisan queue:flush7. Scheduled Tasks
php artisan schedule:runphp artisan schedule:list8. Environment
php artisan envphp artisan key:generate9. Testing
php artisan test10. Custom Artisan Commands
php artisan custom:taskapp/Console/Commands/)Bonus: Tinker (Interactive Console)
php artisan tinkerphp artisan list at any time to see all the available commands for your specific Laravel version.
