Artisan Commands Documentation
Complete reference for Laravel Artisan commands with examples and best practices.
Command Categories
Quick Actions
Make Commands
Generate new files and classes
15 commands
make:controller
make
Create a new controller class
Syntax
php artisan make:controller {name}
Options
Option | Description |
---|---|
--resource | Generate a resource controller |
--api | Generate an API resource controller |
--invokable | Generate a single method, invokable controller |
--model= | Generate a resource controller for the given model |
--parent= | Generate a nested resource controller |
Examples
php artisan make:controller UserController
Create a basic controller
php artisan make:controller UserController --resource
Create a resource controller with CRUD methods
php artisan make:controller API/UserController --api
Create an API resource controller
make:model
make
Create a new Eloquent model class
Syntax
php artisan make:model {name}
Options
Option | Description |
---|---|
-m, --migration | Create a new migration file for the model |
-c, --controller | Create a new controller for the model |
-r, --resource | Create a resource controller for the model |
-f, --factory | Create a new factory for the model |
-s, --seeder | Create a new seeder for the model |
--all | Generate all related files (migration, factory, seeder, controller) |
Examples
php artisan make:model User
Create a basic model
php artisan make:model User -m
Create model with migration
php artisan make:model User --all
Create model with all related files
make:migration
make
Create a new database migration
Syntax
php artisan make:migration {name}
Options
Option | Description |
---|---|
--create= | The table to be created |
--table= | The table to migrate |
--path= | The location where the migration file should be created |
Examples
php artisan make:migration create_users_table
Create a new table migration
php artisan make:migration add_email_to_users_table --table=users
Add column to existing table
make:seeder
make
Create a new seeder class
Syntax
php artisan make:seeder {name}
Examples
php artisan make:seeder UserSeeder
Create a new seeder
make:factory
make
Create a new model factory
Syntax
php artisan make:factory {name}
Options
Option | Description |
---|---|
--model= | The name of the model |
Examples
php artisan make:factory UserFactory
Create a new factory
php artisan make:factory UserFactory --model=User
Create factory for specific model
make:middleware
make
Create a new middleware class
Syntax
php artisan make:middleware {name}
Examples
php artisan make:middleware CheckAge
Create a new middleware
make:request
make
Create a new form request class
Syntax
php artisan make:request {name}
Examples
php artisan make:request StoreUserRequest
Create a new form request
make:resource
make
Create a new API resource
Syntax
php artisan make:resource {name}
Options
Option | Description |
---|---|
--collection | Create a resource collection |
Examples
php artisan make:resource UserResource
Create a new API resource
php artisan make:resource UserCollection --collection
Create a resource collection
make:job
make
Create a new job class
Syntax
php artisan make:job {name}
Options
Option | Description |
---|---|
--sync | Create a synchronous job |
Examples
php artisan make:job ProcessPayment
Create a new job
make:mail
make
Create a new email class
Syntax
php artisan make:mail {name}
Options
Option | Description |
---|---|
--markdown= | Create a new Markdown template for the mailable |
Examples
php artisan make:mail OrderShipped
Create a new mailable
php artisan make:mail OrderShipped --markdown=emails.orders.shipped
Create mailable with Markdown template
make:notification
make
Create a new notification class
Syntax
php artisan make:notification {name}
Options
Option | Description |
---|---|
--markdown= | Create a new Markdown template for the notification |
Examples
php artisan make:notification InvoicePaid
Create a new notification
make:event
make
Create a new event class
Syntax
php artisan make:event {name}
Examples
php artisan make:event OrderShipped
Create a new event
make:listener
make
Create a new event listener class
Syntax
php artisan make:listener {name}
Options
Option | Description |
---|---|
--event= | The event class being listened for |
--queued | Indicates the event listener should be queued |
Examples
php artisan make:listener SendShipmentNotification
Create a new listener
php artisan make:listener SendShipmentNotification --event=OrderShipped
Create listener for specific event
make:provider
make
Create a new service provider class
Syntax
php artisan make:provider {name}
Examples
php artisan make:provider CustomServiceProvider
Create a new service provider
make:command
make
Create a new Artisan command
Syntax
php artisan make:command {name}
Options
Option | Description |
---|---|
--command= | The terminal command that should be assigned |
Examples
php artisan make:command SendEmails
Create a new command
php artisan make:command SendEmails --command=email:send
Create command with specific signature