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

OptionDescription
--resourceGenerate a resource controller
--apiGenerate an API resource controller
--invokableGenerate 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

OptionDescription
-m, --migrationCreate a new migration file for the model
-c, --controllerCreate a new controller for the model
-r, --resourceCreate a resource controller for the model
-f, --factoryCreate a new factory for the model
-s, --seederCreate a new seeder for the model
--allGenerate 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

OptionDescription
--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

OptionDescription
--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

OptionDescription
--collectionCreate 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

OptionDescription
--syncCreate 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

OptionDescription
--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

OptionDescription
--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

OptionDescription
--event=The event class being listened for
--queuedIndicates 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

OptionDescription
--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