Evolving Entities
Generators are great on day 1 and useless on day 30, because regenerating wipes your manual changes. --add-fields patches instead of regenerating.
Add fields to an existing entity
php artisan make:fullapi Post --add-fields="excerpt:text,status:enum(draft,published)"
php artisan migrateWhat happens:
- An incremental
Schema::table()migration is created (with a properdown()) $fillable,$castsand the PHPDoc block of the existing model are patched in place- Validation rules, factory values and resource fields are inserted where they belong
- The enum class is generated when needed
- Fields that already exist are skipped; your custom methods are never touched
The DTO (constructor promotion) and the generated tests are left alone and reported as manual follow-ups.
Regenerate specific files
Changed your mind about a single artifact? --only= rewrites just the listed generators and leaves the migration, route and seeder registration untouched:
php artisan make:fullapi Post --fields="title:string,content:text" --only=Resource
php artisan make:fullapi Post --fields="title:string,content:text" --only=FeatureTest,UnitTestAvailable types: Model, Controller, Service, DTO, Request, Resource, Migration, Factory, Seeder, Policy, FeatureTest, UnitTest.
Delete cleanly
php artisan delete:fullapi PostRemoves every generated file, unregisters the seeder from DatabaseSeeder.php, and strips the entity's routes from routes/api.php and routes/web.php.
Repair orphan routes
If a route file still references a deleted controller (the classic route:list ReflectionException), purge orphan lines:
php artisan api-generator:clean-routes --dry-runphp artisan api-generator:clean-routesThe VS Code extension offers this fix automatically when List Routes fails on an orphan controller.
