
On this page
Laravel Artisan commands you should know
Laravel Artisan is a powerful command-line tool that significantly improves a developer’s productivity by automating repetitive and time‑consuming tasks. From generating boilerplate code to managing database migrations, queues, caches, and configurations, Artisan allows you to focus more on writing clean, maintainable code rather than handling routine operations manually.
Whether you are just starting with Laravel or already building production‑ready applications, learning and using Artisan commands regularly can drastically improve your development workflow.
Artisan is the command-line interface (CLI) that comes bundled with Laravel. It provides a wide range of helpful commands to assist you while building, testing, and maintaining your application. To view all available Artisan commands, you can use:
php artisan list
On this page
Creating Controllers in Laravel
Artisan makes it easy to generate controllers with a single command.
php artisan make:controller UserController
Create a resource controller:
php artisan make:controller CategoriesController --resource
Create a controller inside a sub‑directory:
php artisan make:controller Blog/PostsController
Creating Components
Laravel allows you to generate reusable UI components using Artisan.
php artisan make:component Header
laravel new project_name
php artisan make:auth
php artisan route:list
php artisan migrate:refresh
php artisan migrate:refresh --seed php artisan migrate --seed
php artisan ui vue --auth
Model With Migration
php artisan make:model Post -m
php artisan make:model Category -m
php artisan route:clear
php artisan optimize
php artisan up
php artisan down
php artisan config:cache
php artisan migrate:rollback
php artisan migrate --path=/database/migrations/2019_10_06_052849_create_categories_table.php
php artisan help migrate
php artisan make:request CreateCategoryRequest
php artisan make:request Categories/CreateCategoryRequest
php artisan storage:link
php artisan make:migration create_post_tag_table --table=post_tag
php artisan cache:clear
php artisan make:resource CategoriesResource
php artisan make:middleware VerifyCategoriesCount
php artisan make:seeder PostsTableSeeder
php artisan migrate:refresh --seed
php artisan vendor:publish
php artisan make:factory ModelFactory
php artisan make:seed ProductsTableSeeder
php artisan schedule:list
php artisan key:generate
Laravel Tinker
Laravel Tinker allows you to interact with a database without creating the routes. Laravel tinker is used with a php artisan to create the objects or modify the data. Tinker is a command tool that works with a php artisan. A tinker plays around the database means that it allows you to create the objects, insert the data, etc.
php artisan tinker User::all(); exit
Composer
Composer is an application-level dependency manager for the PHP programming language that provides a standard format for managing dependencies of PHP software and required libraries.
composer require laravel/ui
composer update
How to Send Database Notifications
Create a Notifications Table
php artisan notifications:table
Generating Notifications
php artisan make:notification DepositSuccessful
Important artisan commands
| Command | Description |
|---|---|
| php artisan list | List all available Artisan commands. |
| php artisan serve | |
| php artisan key:generate | |
| php artisan db:seed –class=PermissionTableSeeder | |
| php artisan db:seed –class=CreateAdminUserSeeder | |
| php artisan db:seed | Seed the database with records. |
| php artisan migrate:rollback –path=database/migrations/2023_08_17_095957_create_mails_table.php | |
| php artisan migrate:rollback | will run down() method |
| php artisan migrate:refresh –seed | |
| php artisan migrate | will run up() method |
| php artisan migrate:fresh | |
| php artisan migrate:reset | |
| php artisan make:migration add_column_to_users_table –table=users | |
| php artisan make:controller ResourcesController –resource | |
| php artisan make:mail OrderShipped | |
| php artisan make:seeder MailSeeder | |
| php artisan make:seeder MailSeeder | |
| php artisan make:component InputLabel | |
| php artisan datatables:make Users | |
| php artisan config:clear | |
| php artisan tinker | |
| php artisan test | Run PHPUnit tests. |
| php artisan test –filter=ArticleTest | Run PHPUnit tests. (Single Class) |
| php artisan make:test ArticleTest | Create a new test class. |
| php artisan config:cache | Cache the configuration files. |
| php artisan config:clear | Clear the configuration cache. |
| php artisan schedule:list | List the scheduled tasks. |
| php artisan route:list | List all registered routes. |
| php artisan route:clear | Clear route cache. |
| php artisan make:model Todo -a | create model, controller and migration in single artisan command |
| php artisan –version | Laravel Framework Version |
Laravel Artisan plays a vital role in speeding up development and simplifying everyday tasks in a Laravel application. By leveraging its built-in commands, developers can focus more on writing quality code instead of handling repetitive work manually. As you continue working with Laravel, regularly using Artisan commands will help you become more productive, maintain cleaner code, and build applications more efficiently. Exploring and mastering Artisan is a small effort that delivers long-term benefits in your Laravel development journey.
- END -



