The make:fullapi Command
make:fullapi is the heart of the package. It accepts an entity name with inline fields, or reads from a schema file, a Mermaid diagram or your existing database.
Basic usage
php artisan make:fullapi Post --fields="title:string,content:text,published:boolean"Soft deletes
php artisan make:fullapi Post --fields="title:string,content:text" --soft-deletesAdds the SoftDeletes trait, a softDeletes() migration column, restore() / forceDelete() methods, and two extra routes that still find a soft deleted post:
POST /api/posts/{post}/restore
DELETE /api/posts/{post}/force-deleteSanctum authentication
php artisan make:fullapi Post --fields="title:string" --authScaffolds a complete token-based auth system: AuthController (register, login, logout, user), LoginRequest, RegisterRequest, public auth routes, and wraps your API resource routes inside auth:sanctum middleware.
| Method | Route | Access |
|---|---|---|
POST | /api/register | Public, limited to 6 requests per minute |
POST | /api/login | Public, limited to 6 requests per minute |
POST | /api/logout | auth:sanctum |
GET | /api/user | auth:sanctum |
GET | /api/posts | auth:sanctum (your resources require a token too) |
Then install Sanctum if not already present:
composer require laravel/sanctum
php artisan vendor:publish --provider="Laravel\Sanctum\SanctumServiceProvider"
php artisan migratePostman collection
php artisan make:fullapi Post --fields="title:string" --postmanExports a postman_collection.json (v2.1 schema) at the project root: a folder per entity with List, Create, Show, Update and Delete requests pre-filled with sample data. See API Docs & Postman.
Pagination, filters and sorting
Every generated index endpoint is paginated, filterable and sortable:
GET /api/posts?filter[status]=draft&sort=-created_at,title&page=2&per_page=20The response carries data, links and meta. Filters match exact values on the primary key and the fillable columns (JSON columns excluded). sort takes a comma-separated list where a leading - means descending, and the default order is the primary key, newest first. Unknown filters and sorts are ignored.
per_page defaults to 15 and stops at 100. To change these values, publish the config before generating. They are written into each generated service, so the generated code never reads the package at runtime.
php artisan vendor:publish --tag=api-generator-configWith Spatie QueryBuilder
composer require spatie/laravel-query-builder
php artisan make:fullapi Post --fields="title:string,content:text" --query-builderThe same parameters then go through spatie/laravel-query-builder, with exact filters, the same sortable columns and the same pagination. Spatie answers 400 for an unknown filter or sort instead of ignoring it. For partial matches, swap AllowedFilter::exact for AllowedFilter::partial in the service.
The flag works with every generation mode, and query_builder: true can be set globally or per entity in a schema file.
Pest tests
php artisan make:fullapi Post --fields="title:string" --pestGenerates it(...) / expect(...) style tests instead of PHPUnit classes, with the same coverage. See Generated Tests.
Interactive wizard
php artisan make:fullapi --interactiveA step-by-step guided setup: entity name, fields one by one (type, nullable, unique, default), relationships, options, and a full preview before generation. Ideal for configuring constraints not available in the --fields string syntax.
Regenerate selected files with --only=
To rebuild a Resource or a Test without touching everything else:
php artisan make:fullapi Post --only=FeatureTest,UnitTestThe fields, relations and options come from the definition recorded when the entity was generated. An entity generated before 4.1 needs its --fields once (see Regenerate specific files).
When --only= is set, the migration, the apiResource route and the DatabaseSeeder registration are left untouched: only the listed artifacts are rewritten. A listed file you edited by hand is kept unless you add --force (see Evolving Entities).
Available types: Model, Controller, Service, DTO, Request, Resource, Migration, Factory, Seeder, Policy, FeatureTest, UnitTest.
Deleting an entity
php artisan delete:fullapi PostAfter a confirmation, removes all generated files, unregisters the seeder from DatabaseSeeder.php, and cleans the entity's routes from routes/api.php and routes/web.php. Called without an entity name, it deletes every entity defined in class_data.json. Add --force to skip the question in scripts, or --dry-run to list what would be removed without deleting anything.
If older deletions left routes pointing at controllers that no longer exist (the classic route:list ReflectionException), purge them:
php artisan api-generator:clean-routes --dry-runphp artisan api-generator:clean-routesAll options combined
php artisan make:fullapi Post --fields="title:string,content:text" --soft-deletes --postman --auth --pestThe full flag list lives in the CLI Reference.
