Source + website, updated for Laravel 10
- make:cast Create a new custom Eloquent cast class
- make:channel Create a new channel class
- make:command Create a new Artisan command
- make:component Create a new view component class
- make:controller Create a new controller class
- make:event Create a new event class
- make:exception Create a new custom exception class
- make:factory Create a new model factory
- make:job Create a new job class
- make:listener Create a new event listener class
- make:mail Create a new email class
- make:middleware Create a new middleware class
- make:migration Create a new migration file
- make:model Create a new Eloquent model class
- make:notification Create a new notification class
- make:observer Create a new observer class
- make:policy Create a new policy class
- make:provider Create a new service provider class
- make:request Create a new form request class
- make:resource Create a new resource
- make:rule Create a new validation rule
- make:scope Create a new scope class
- make:seeder Create a new seeder class
- make:test Create a new test class
Note : make:auth has been removed in Laravel 6.
Note : most of commands have the [-f|--force] option to create the class even if file already exists.
Note : most of commands have the [--test] [--pest] options to generate an accompanying PHPUnit / Pest test for the class.
This command creates a new custom Eloquent cast class in app/Casts. Doc
php artisan make:cast [--inbound] <name>--inboundGenerate an inbound cast class. Doc
php artisan make:cast Json
php artisan make:cast Hash --inboundCreate a new channel class for broadcasting in app/Broadcasting. Doc
php artisan make:channel <name>php artisan make:channel OrderChannelThis command creates a new Artisan command in app/Console/Commands. Doc
php artisan make:command [--command [COMMAND]] <name>--commandThe terminal command that will be used to invoke the class. Officially undocumented parameter.
php artisan make:command SendEmailsThis command creates a new view component class in app/View/Components. Doc
php artisan make:component [--inline] [--view] <name>Note : if the
--inlineoption is not set, a file will be created inresources/views/components.
--inlineCreate a component that renders an inline view. Doc--viewCreate an anonymous component with only a view.
php artisan make:component Alert
php artisan make:component Forms/Input
php artisan make:component forms.input --view
php artisan make:component Alert --inlineThis command creates a new controller class in app/Http/Controllers. Doc
php artisan make:controller [--api] [-i|--invokable] [-m|--model [MODEL]] [-p|--parent [PARENT]] [-r|--resource] [-R|--requests] [-s|--singleton] [--creatable] [--type [TYPE]] <name>-r, --resourceThe controller will contain a method for each of the available resource operations – index(), create(), store(), show(), edit(), update(), destroy(). Doc--apiSimilar to--resourceabove, but exclude the create and edit methods (because forms are not needed for API). Doc-i, --invokableGenerates controller with one__invoke()method. Doc-m, --modelIf you are using route model binding and would like the resource controller’s methods to type-hint a model instance. Creates file inapp/Models. Doc-p, --parentGenerate a nested resource controller class. Note : failed to generate a Controller properly. Officially undocumented parameter.-R, --requestsGenerate FormRequest classes for store and update. To use with the--modeloption. Creates files inapp/Http/Requests. Doc-s, --singletonGenerate a singleton resource controller class. Addsabort(404)for the methods create, store and destroy. Officially undocumented parameter.--creatableIndicate that a singleton resource should be creatable. Officially undocumented parameter.--typeManually specify the controller stub file to use. Officially undocumented parameter.
php artisan make:controller UserController
php artisan make:controller ProvisionServer --invokable
php artisan make:controller PhotoController --resource
php artisan make:controller PhotoController --model=Photo --resource
php artisan make:controller PhotoController --model=Photo --resource --requests
php artisan make:controller PhotoController --apiThis command creates a new event class in app/Events. Doc
php artisan make:event <name>php artisan make:event PodcastProcessedThis command creates a new custom exception class in app/Exceptions. Officially undocumented command.
php artisan make:exception <name>--renderCreate the exception with an empty render method.--reportCreate the exception with an empty report method.
This command creates a new model factory in database/factories. Doc
php artisan make:factory [-m|--model [MODEL]] <name>-m, --modelThe name of the model. Officially undocumented parameter.
php artisan make:factory PostFactoryThis command creates a new job class in app/Jobs. Doc
php artisan make:job [--sync] <name>--syncIndicates that job should be synchronous. Officially undocumented parameter.
php artisan make:job ProcessPodcastThis command creates a new event listener class in app/Listeners. Doc
php artisan make:listener [-e|--event [EVENT]] [--queued] <name> -e, --eventThe event class being listened for.--queuedIndicates the event listener should be queued. Officially undocumented parameter.
php artisan make:listener SendPodcastNotification --event=PodcastProcessedThis command creates a new email class in app/Mail. Doc
php artisan make:mail [-m|--markdown [MARKDOWN]] <name>-m, --markdownCreate a new Markdown template for the mailable inresouces/views. Doc
php artisan make:mail OrderShipped
php artisan make:mail OrderShipped --markdown=mail.orders.shippedThis command creates a new middleware class in app/Http/Middleware. Doc
php artisan make:middleware <name>php artisan make:middleware EnsureTokenIsValidThis command creates a new migration file in database/migrations. Doc
Note : file will be generated with timestamp, like this :
[Y]_[m]_[d]_[His]_<name>.php
Runphp artisan migrateto run migration.
Runphp artisan migrate:refresh --seedto reset database with seed values.
php artisan make:migration [--create [CREATE]] [--table [TABLE]] [--path [PATH]] [--realpath] [--fullpath] <name>--createThe table to be created. Officially undocumented parameter.--tableThe table to migrate. Officially undocumented parameter.--pathThe location where the migration file should be created.--realpathIndicate any provided migration file paths are pre-resolved absolute path. Officially undocumented parameter.--fullpathOutput the full path of the migration. Officially undocumented parameter.
php artisan make:migration create_flights_tableThis command creates a new Eloquent model class in app/Models. Doc
php artisan make:model [-a|--all] [-c|--controller] [-f|--factory] [-m|--migration] [--morph-pivot] [--policy] [-s|--seed] [-p|--pivot] [-r|--resource] [--api] [-R|--requests] <name>Short syntax :
php artisan make:model -mcr <name>
-a, --allGenerate a migration, seeder, factory, policy, resource controller, and form request classes for the model.-c, --controllerCreate a new controller for the model.-f, --factoryCreate a new factory for the model.-m, --migrationCreate a new migration file for the model.--morph-pivotIndicates if the generated model should be a custom polymorphic intermediate table model. Officially undocumented parameter.--policyCreate a new policy for the model.-s, --seedCreate a new seeder for the model.-p, --pivotIndicates if the generated model should be a custom intermediate table model.-r, --resourceIndicates if the generated controller should be a resource controller.--apiIndicates if the generated controller should be an API resource controller.-R, --requestsCreate new form request classes and use them in the resource controller.
php artisan make:model Flight
php artisan make:model Flight --migration
# Generate a model and a FlightFactory class...
php artisan make:model Flight --factory
php artisan make:model Flight -f
# Generate a model and a FlightSeeder class...
php artisan make:model Flight --seed
php artisan make:model Flight -s
# Generate a model and a FlightController class...
php artisan make:model Flight --controller
php artisan make:model Flight -c
# Generate a model, FlightController resource class, and form request classes...
php artisan make:model Flight --controller --resource --requests
php artisan make:model Flight -crR
# Generate a model and a FlightPolicy class...
php artisan make:model Flight --policy
# Generate a model and a migration, factory, seeder, and controller...
php artisan make:model Flight -mfsc
# Shortcut to generate a model, migration, factory, seeder, policy, controller, and form requests...
php artisan make:model Flight --all
# Generate a pivot model...
php artisan make:model Member --pivot
php artisan make:model Member -pThis command creates a new notification class in app/Notifications. Doc
php artisan make:notification [-m|--markdown [MARKDOWN]] <name>-m, --markdownCreate a new Markdown template for the notification inresouces/views. Doc
php artisan make:notification InvoicePaid
php artisan make:notification InvoicePaid --markdown=mail.invoice.paidThis command creates a new observer class in app/Observers. Doc
php artisan make:observer [-m|--model [MODEL]] <name>-m, --modelThe model that the observer applies to.
php artisan make:observer UserObserver --model=UserThis command creates a new policy class in app/Policies. Doc
php artisan make:policy [-m|--model [MODEL]] [-g|--guard [GUARD]] <name>-m, --modelThe model that the policy applies to.-g, --guardThe guard that the policy relies on. Officially undocumented parameter.
php artisan make:policy PostPolicy
php artisan make:policy PostPolicy --model=PostThis command creates a new service provider class in app/Providers. Doc
php artisan make:provider <name>php artisan make:provider RiakServiceProviderThis command creates a new form request class in app/Http/Requests. Doc
php artisan make:request <name>php artisan make:request StorePostRequestThis command creates a new resource in app/Http/Resources. Doc
php artisan make:resource [-c|--collection] <name>-c, --collectionCreate a ResourceCollection instead of individual Resource class. Doc
php artisan make:resource UserResource
php artisan make:resource User --collection
php artisan make:resource UserCollectionThis command creates a new validation rule in app/Rules. Doc
php artisan make:rule [-i|--implicit] <name>-i, --implicitGenerate an implicit rule. Doc
php artisan make:rule Uppercase
php artisan make:rule Uppercase --implicitThis command creates a new scope class in app/Models/Scopes. Doc
php artisan make:scope <name>php artisan make:scope AncientScopeThis command creates a new database seeder class in database/seeders. Doc
php artisan make:seeder <name>php artisan make:seeder UserSeederThis command creates a new test class in test/Feature. Doc
php artisan make:test [-u|--unit] [-p|--pest] <name>-u, --unitCreate a unit test intest/Unit.-p, --pestCreate a Pest test.
php artisan make:test UserTest --unit --pest
Good