Reader Stacks

Generating Controllers, Models, and More With Artisan

The -a flag on make:model generates a controller, factory, seeder, migration, and policy in one single command — genuinely faster than running five separate generator commands for a brand-new resource.

Laravel's Artisan generator commands scaffold the boilerplate for every major building block — models, controllers, migrations, and more — and several flags combine multiple generators into a single command for a faster start on a new resource.

Generating a model

php artisan make:model Product

Generating a model with its migration in one command

php artisan make:model Product -m

-m additionally creates a matching migration file — genuinely convenient, since a new Eloquent model almost always needs a corresponding database table, and this saves a separate make:migration call.

Generating a model with a full set of related files at once

php artisan make:model Product -a

-a ("all") generates the model along with its migration, factory, seeder, controller (as a resource controller), and policy — genuinely faster than the equivalent five separate generator commands when starting a brand-new resource that will need all of these pieces.

Generating just a controller

php artisan make:controller ProductController
php artisan make:controller ProductController --resource
php artisan make:controller Api/ProductController --api

Generating a controller with a specific model already wired in

php artisan make:controller ProductController --resource --model=Product

--model=Product type-hints Product directly in each generated method's signature (using route-model binding) — a small but genuinely useful time-saver over manually adding the type-hint to all seven resource methods afterward.

Generating a migration on its own

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

Generating a factory

php artisan make:factory ProductFactory --model=Product

Generating a form request

php artisan make:request StoreProductRequest

Generating a policy

php artisan make:policy ProductPolicy --model=Product

Generating a Blade component

php artisan make:component Alert

Listing every available make: generator

php artisan list make

This lists every registered make:* command with a brief description — genuinely useful for discovering a less commonly used generator (like make:observer or make:cast) that isn't part of the everyday model/controller/migration trio most developers reach for by default.

Why using generators consistently matters beyond just saving typing

Beyond the time saved, using the correct generator consistently keeps a project's file naming, namespace structure, and boilerplate aligned with Laravel's own conventions — a manually created file that deviates even slightly from the expected naming or namespace pattern can cause subtle autoloading or convention-based resolution issues that a generated file, following the framework's own template exactly, avoids by construction.