Back to Blog
17 Feb 2025

Laravel Artisan Commands Every Laravel Developer Should Know

A practical guide to essential Laravel Artisan commands that help developers manage applications, generate code, work with databases, debug issues, clear caches, and improve everyday Laravel development workflows.

Laravel Artisan Commands Every Laravel Developer Should Know

Laravel Artisan is one of the most useful tools available to Laravel developers. It provides a command-line interface for performing common development and application-management tasks.

Whether you are creating controllers, working with migrations, clearing caches, checking routes, or debugging an application, Artisan can significantly speed up your workflow.

In this guide, we will look at some of the most useful Artisan commands that Laravel developers should know.

1. Check Laravel Version

php artisan --version

This command displays the Laravel version currently installed in your project.

It is useful when checking the framework version before installing packages, debugging compatibility issues, or working on an existing project.

2. List Available Commands

php artisan list

This displays the available Artisan commands in your Laravel application.

It is useful when you are unsure which command is available for a particular task.

3. Create a Controller

php artisan make:controller ProductController

Laravel can automatically generate controllers using the make:controller command.

4. Create a Model

php artisan make:model Product

Models are used to interact with database tables through Laravel's Eloquent ORM.

You can also generate a model together with a migration:

php artisan make:model Product -m

5. Create a Migration

php artisan make:migration create_products_table

Migrations allow developers to define and modify database structures using PHP code.

After creating a migration:

php artisan migrate

6. Check Migration Status

php artisan migrate:status

This command shows which migrations have already been executed and which migrations are still pending.

It is particularly useful when troubleshooting database-related issues.

7. Roll Back Migrations

php artisan migrate:rollback

This rolls back the latest migration batch.

It can be useful during development when you need to undo a recent database change.

8. Clear Laravel Caches

php artisan optimize:clear

This is one of the most useful commands when troubleshooting Laravel applications.

It clears Laravel's cached configuration, routes, views, events, and other optimized files.

9. Check Application Routes

php artisan route:list

This displays the routes registered in the application.

It is extremely useful when debugging routing problems and checking middleware, HTTP methods, controllers, and route names.

10. Create a Form Request

php artisan make:request StoreProductRequest

Form Requests allow validation and authorization logic to be separated from controllers.

This helps keep controllers cleaner and easier to maintain.

11. Create an API Resource

php artisan make:resource UserResource

Laravel API Resources allow developers to control how model data is transformed before being returned from an API.

They are particularly useful when building REST APIs.

12. Use Laravel Tinker

php artisan tinker

Tinker provides an interactive shell for working with Laravel applications.

It can be used to query models, test relationships, and experiment with application logic without creating temporary routes or controllers.

13. Create a Seeder

php artisan make:seeder UserSeeder

Seeders are used to populate the database with initial or test data.

You can execute seeders with:

php artisan db:seed

You can also migrate and seed together:

php artisan migrate --seed

14. Create Middleware

php artisan make:middleware AdminMiddleware

Middleware can inspect and filter HTTP requests before they reach the application's controller.

They are commonly used for authentication, authorization, role checking, and request filtering.

15. Work With Queues

php artisan queue:work

Laravel queues allow time-consuming tasks to be processed in the background.

They are useful for tasks such as sending emails, processing files, generating reports, and other operations that should not block a web request.

16. Check Scheduled Tasks

php artisan schedule:list

This command helps inspect scheduled tasks configured in a Laravel application.

Scheduled tasks are useful for recurring jobs such as reports, cleanup operations, notifications, and automated maintenance.

17. Clear Configuration Cache

php artisan config:clear

This command clears the cached configuration.

It can be useful when configuration or environment changes are not being reflected as expected.

Conclusion

Laravel Artisan provides a powerful collection of commands that can make everyday development significantly easier.

Instead of manually creating files, modifying database structures, checking routes, or troubleshooting cached resources, developers can use Artisan to perform many of these tasks quickly and consistently.

The best way to become comfortable with Artisan is to use these commands regularly while building real Laravel applications.Laravel Artisan Commands Every Laravel Developer Should Know

Laravel Artisan is one of the most useful tools available to Laravel developers. It provides a command-line interface for performing common development and application-management tasks.

Whether you are creating controllers, working with migrations, clearing caches, checking routes, or debugging an application, Artisan can significantly speed up your workflow.

In this guide, we will look at some of the most useful Artisan commands that Laravel developers should know.

1. Check Laravel Version

php artisan --version

This command displays the Laravel version currently installed in your project.

It is useful when checking the framework version before installing packages, debugging compatibility issues, or working on an existing project.

2. List Available Commands

php artisan list

This displays the available Artisan commands in your Laravel application.

It is useful when you are unsure which command is available for a particular task.

3. Create a Controller

php artisan make:controller ProductController

Laravel can automatically generate controllers using the make:controller command.

4. Create a Model

php artisan make:model Product

Models are used to interact with database tables through Laravel's Eloquent ORM.

You can also generate a model together with a migration:

php artisan make:model Product -m

5. Create a Migration

php artisan make:migration create_products_table

Migrations allow developers to define and modify database structures using PHP code.

After creating a migration:

php artisan migrate

6. Check Migration Status

php artisan migrate:status

This command shows which migrations have already been executed and which migrations are still pending.

It is particularly useful when troubleshooting database-related issues.

7. Roll Back Migrations

php artisan migrate:rollback

This rolls back the latest migration batch.

It can be useful during development when you need to undo a recent database change.

8. Clear Laravel Caches

php artisan optimize:clear

This is one of the most useful commands when troubleshooting Laravel applications.

It clears Laravel's cached configuration, routes, views, events, and other optimized files.

9. Check Application Routes

php artisan route:list

This displays the routes registered in the application.

It is extremely useful when debugging routing problems and checking middleware, HTTP methods, controllers, and route names.

10. Create a Form Request

php artisan make:request StoreProductRequest

Form Requests allow validation and authorization logic to be separated from controllers.

This helps keep controllers cleaner and easier to maintain.

11. Create an API Resource

php artisan make:resource UserResource

Laravel API Resources allow developers to control how model data is transformed before being returned from an API.

They are particularly useful when building REST APIs.

12. Use Laravel Tinker

php artisan tinker

Tinker provides an interactive shell for working with Laravel applications.

It can be used to query models, test relationships, and experiment with application logic without creating temporary routes or controllers.

13. Create a Seeder

php artisan make:seeder UserSeeder

Seeders are used to populate the database with initial or test data.

You can execute seeders with:

php artisan db:seed

You can also migrate and seed together:

php artisan migrate --seed

14. Create Middleware

php artisan make:middleware AdminMiddleware

Middleware can inspect and filter HTTP requests before they reach the application's controller.

They are commonly used for authentication, authorization, role checking, and request filtering.

15. Work With Queues

php artisan queue:work

Laravel queues allow time-consuming tasks to be processed in the background.

They are useful for tasks such as sending emails, processing files, generating reports, and other operations that should not block a web request.

16. Check Scheduled Tasks

php artisan schedule:list

This command helps inspect scheduled tasks configured in a Laravel application.

Scheduled tasks are useful for recurring jobs such as reports, cleanup operations, notifications, and automated maintenance.

17. Clear Configuration Cache

php artisan config:clear

This command clears the cached configuration.

It can be useful when configuration or environment changes are not being reflected as expected.

Conclusion

Laravel Artisan provides a powerful collection of commands that can make everyday development significantly easier.

Instead of manually creating files, modifying database structures, checking routes, or troubleshooting cached resources, developers can use Artisan to perform many of these tasks quickly and consistently.

The best way to become comfortable with Artisan is to use these commands regularly while building real Laravel applications.