Reader Stacks

Laravel Artisan Generator Commands: Controllers, Models, and More

make:model --all is the one flag worth knowing that most tutorials skip — it scaffolds the model, migration, factory, seeder, and controller together in a single command.

Laravel Artisan Generator Commands: Controllers, Models, and More

Laravel's Artisan generator commands scaffold the boilerplate for nearly every type of class in a typical application — knowing the specific flags that combine several related generators into one command saves real, repeated typing across a project.

Generating a controller

php artisan make:controller ProductController
php artisan make:controller ProductController --resource   // includes all 7 RESTful methods
php artisan make:controller ProductController --api        // resource methods, minus create/edit (no views needed for an API)

Generating a model

php artisan make:model Product

Generating a model with its migration in one command

php artisan make:model Product -m

The all-in-one flag: model, migration, factory, seeder, and controller together

php artisan make:model Product --all

--all generates the model, a migration, a factory, a seeder, and a resource controller in one single command — genuinely useful for scaffolding a new Eloquent entity's full boilerplate at once, rather than running five separate generator commands in sequence.

Generating just a migration

php artisan make:migration create_products_table
php artisan make:migration add_sku_to_products_table --table=products

Generating a Form Request

php artisan make:request StoreProductRequest

Generating a factory

php artisan make:factory ProductFactory --model=Product

Generating a seeder

php artisan make:seeder ProductSeeder

Generating an API Resource

php artisan make:resource ProductResource

Generating a policy

php artisan make:policy ProductPolicy --model=Product

The --model flag on make:policy pre-fills the generated policy with the standard method stubs (view, create, update, delete) already type-hinted against the specified model, rather than generating a completely empty policy class.

Listing every available make: command

php artisan list make

Running this shows every generator Artisan currently supports, including ones for jobs, events, listeners, notifications, mail classes, and more — genuinely useful for discovering a specific generator that exists but isn't commonly referenced in tutorials.

Why using generators consistently matters beyond just saving typing

Beyond the time saved, using the generator commands consistently ensures every class of a given type follows the same file location and namespace convention Laravel expects — manually creating a class by hand risks a subtle naming or namespace mismatch that Artisan's generators handle correctly by construction every time.