caminodeldev/laravel-api-scaffold
A Laravel scaffolding package for building APIs faster: generate boilerplate controllers, routes, resources, requests, and validation so new JSON endpoints stay consistent and ready to extend. Great for prototyping and starting projects with a clean, conventional structure.
Architecture fit: laravel-api-scaffold remains a code-generation tool layered on standard Laravel conventions (Artisan commands, Eloquent models, migrations introspection). v0.4.0 does not introduce a runtime dependency or middleware/extension surface — the generated models use vanilla belongsTo/hasMany and standard decimal:2 casts. That keeps architectural coupling low: the package can be adopted by a single team on a single bounded context without touching application bootstrapping.
What changed that matters to a TPM:
local column, referenced table, referenced column, constraint name, inverse references).belongsTo (child) and hasMany (parent) relationships plus PHPDoc @property blocks for columns and relations.models config block with three knobs: generate_relationships, generate_phpdoc, phpdoc_decimal_type (default string, aligning PHPDoc with Laravel's decimal:N cast returning strings).scaffold:model and scaffold:api emit the enriched output; imports (BelongsTo, HasMany, Collection, Carbon) are emitted only when needed.Integration feasibility: High for greenfield or convention-following schemas. The release is opt-in by configuration, and — critically — existing generated files are unchanged until someone re-runs the generator. Upgrade risk is therefore near zero at runtime and concentrated entirely in the regeneration step. Both consumer validations (MySQL and PostgreSQL) exercised the full path: publish config → scaffold:model → scaffold:api → php -l → generated feature tests pass → runtime relationship calls verified. That is the right evidence set for a scaffolding tool, because it demonstrates the artifact is syntactically and behaviourally sound in a real consumer app, not just inside the package test suite.
Technical risk:
--force overwrite of hand-edited models (highest). The documented regeneration commands use --force. Any consumer that has added custom accessors, scopes, casts, or business logic to a generated model will lose them. This is the single most likely production incident from this release.@property block is worse than none for static analysis (PHPStan/Psalm).scaffoldTransacciones. Collisions with existing methods (user(), items(), model name casing) or PHP-reserved identifiers are not documented as guarded against.belongsToMany, no polymorphic relations. Schemas with pivot tables or morph columns will get a partial model graph that looks complete, which is a subtle correctness trap for reviewers.hasMany fan-out. Every referencing table yields a hasMany on the parent. Hub tables with many inbound FKs will produce large models and larger PHPDoc blocks; no filtering/allow-list is documented.^0.4.0 gives no API stability guarantee; generated output format is a de facto public contract that the package may still change in 0.5.x.--force, which overwrites any consumer customisations to the package config file.Key questions:
--force over existing models?--no-relationships / --no-phpdoc per-invocation flag, or is suppression only via the published config file (which is global)?information_schema visibility), and what happens when introspection returns nothing — silent success or error?Stack fit: Native Laravel/PHP. Fits any LEMP/LAPP or managed-DB estate where Eloquent is the data layer and Artisan is the operational interface. No additional infrastructure, queue, or service dependency is introduced. Works with Octane/Swoole — the notes explicitly cover optimize:clear + octane:reload, which is the signal that the package has been tested against long-lived worker runtimes rather than only FPM.
Migration path (recommended sequencing):
composer require caminodeldev/laravel-api-scaffold:^0.4.0 -W in a feature branch. Given 0.x semantics, consider an exact pin (0.4.0) until v1.0.--force. Confirm the new models block lands with the intended defaults (generate_relationships: true, generate_phpdoc: true, phpdoc_decimal_type: string).Scopes before running --force.config:clear, cache:clear, optimize:clear, octane:reload) as documented — stale config or opcache is the most common cause of "the config option did nothing".scaffold:api only after scaffold:model output is accepted, since scaffold:api regenerates a larger surface (routes, resources, controllers, tests) with the same --force behaviour.Compatibility:
models block requires a republish to be present; teams that skip republishing simply get no relationships/PHPDoc (feature-off by absence), which is a safe fallback but should be documented internally so silence isn't mistaken for a bug.belongsToMany, polymorphic relations. Do not market this internally as "full relationship generation".Rollback: Trivially easy — revert the regenerated files (they are source artifacts) and drop the package version. No migrations, no schema changes, no data implications.
Maintenance: Low ongoing cost, moderate one-off cost. The package itself is a dev dependency whose blast radius is limited to generated files. The real maintenance burden shifts to process: someone must own the decision of when models are regenerated versus hand-edited, and the repo must have a diff-review discipline for generated artifacts. The PHPDoc blocks are the highest-churn element — they will rot silently if schema changes are frequent and regeneration is ad hoc.
Support: Small. Failure surface is generation-time (introspection, naming, file writes) rather than runtime. Support requests will cluster into three predictable categories: overwritten custom code, relationships not appearing (config not republished, wrong --connection, --force not passed), and odd relationship names on non-conventional schemas. Team ramp-up is very low — anyone who can run Artisan commands can use it; the learning is in the guardrails, not the tool.
Scaling:
hasMany fan-out means a small number of hub tables accumulate very large models and PHPDoc. Consider disabling generate_phpdoc selectively, or accepting churn in those files.Failure modes and mitigations:
| Failure | Impact | Detection | Mitigation |
|---|---|---|---|
--force wipes hand-edited model logic |
High — silent loss of business logic | Code review diff | Move customisations to traits; never --force on bespoke models; commit before regenerating |
| Config not republished | Medium — feature silently absent | Generated output lacks relations/PHPDoc | Republish config, config:clear, verify models block present |
| Stale PHPDoc after schema change | Medium — false confidence for static analysis | PHPStan/Psalm drift, or CI regeneration diff | CI job that regenerates and asserts clean diff |
| FK metadata unreadable (privileges, driver quirks) | Medium — models generated with no relationships, no error | Empty output inspection | Validate in staging first; grant metadata read; assert relationship count in CI |
| Unconventional/composite/circular FKs | Medium — odd method names, skipped relations, possible generator loop | Output review | Inventory FK topology before rollout; exclude problem tables |
belongsToMany / morph schemas |
Medium — incomplete model graph that looks complete | Schema review | Document the gap; hand-write those relations |
| Octane/opcache serving stale generated classes | Low–Medium — confusing runtime behaviour | Non-reproducible behaviour post-regeneration | Follow documented optimize:clear + octane:reload |
| Pre-1.0 output format change in 0.5.x | Medium — churn across all generated files | Upgrade diff | Pin exact version; gate upgrades behind a diff review |
Recommendation: Adopt. The release is additive, opt-in, and validated end-to-end on both supported drivers, with a trivially reversible failure mode. Gate adoption on two things before rolling out broadly: (1) an inventory of foreign-key topology to identify composite/circular/pivot cases the release does not cover, and (2) a documented regeneration policy that protects hand-edited models from --force. Treat generated models as reviewed artifacts with a CI drift check, and pin the version exactly until v1.0 given pre-1.0 semantics.
How can I help you explore Laravel packages today?