- How do I install mitulgolakiya/laravel-api-generator?
- Composer installation is likely to fail on current Laravel because the package pins illuminate/support to ^5.0 and was last released in 2015. The practical approach is to run it only in a disposable Laravel 5.x environment against a schema dump, then copy the generated files into your modern app. Do not use --ignore-platform-reqs as a workaround, because it turns a dependency-resolution failure into a runtime failure.
- Does laravel-api-generator support Laravel 10, 11, or 12?
- No. The repository is archived and the last release dates to May 2015, so it does not support Laravel 9, 10, 11, or 12. Its composer constraints and generated code reflect Laravel 5-era conventions, including string-based namespaces and no return types. Treat it as a reference design or a fork candidate, not a dependency for a modern Laravel application.
- What files does Laravel API Generator generate from a database table?
- The package advertises generation of models, controllers, form requests, API resources, routes, and a repository layer from an existing table schema. It also claims pagination, filtering, sorting, and relationship support. Verify each feature against the actual source before relying on it, because API Resources did not ship until Laravel 5.5 and the last release predates that.
- Can I customize the generated controllers, models, and routes?
- Publishable stubs are the intended customization point, letting you change the templates for generated files. You can also vendor and modify the package under its MIT license, which is the safer route for a modern Laravel target. Review the generator's collision and overwrite behavior in a scratch repository before pointing it at real application code.
- Is laravel-api-generator safe to use in production?
- Not as a runtime dependency, and only with a review gate for generated output. Generators from this era typically emit controllers without authorization policies and form requests whose authorize method is a stub, which can leave IDOR issues if shipped unreviewed. The package is also unmaintained, so any security fixes or compatibility work become your responsibility.
- How does it infer relationships and validation rules from my schema?
- It introspects the database via information_schema and infers fields, validation, and relationships from the live schema. Relationship generation depends on explicit foreign key constraints, and validation tends toward permissive rules such as nullable|string when column metadata is thin. Schemas without FKs or comments will produce models with missing relationships and weak validation, so audit the output.
- What are alternatives to laravel-api-generator for Laravel CRUD scaffolding?
- For modern Laravel, start with artisan make commands and hand-written API resources, or use maintained generators such as Reliese Laravel for models and InfyOm for scaffolding. Contract-first OpenAPI tooling is a better fit when the API contract must drive implementation. This package is an alternative only for legacy Laravel 5.x or database-first one-shot scaffolding.
- How do I test APIs generated by laravel-api-generator?
- Treat generated endpoints as ordinary Laravel controllers and cover them with feature tests using PHPUnit or Pest, RefreshDatabase, and factories. Run the generator in a scratch branch or throwaway container so file writes and collisions do not touch your main application. Add tests for authorization and validation because generated code often needs hardening before it is production-ready.
- Why does composer require fail for laravel-api-generator?
- Composer fails because the package's constraints target PHP and illuminate/support 5.x, while modern Laravel requires newer versions that cannot be satisfied together. The repository is archived, so there is no compatibility release to fix the conflict. Ignoring platform requirements may force installation but will not make the generated code or package internals compatible with PHP 8 and Laravel 9–12.
- Is laravel-api-generator suitable for a database-first legacy project or a greenfield Laravel app?
- It fits database-first legacy estates where the live schema is the source of truth and you need a one-shot scaffold. It is a poor fit for greenfield, migration-first Laravel teams or API-first projects already driven by OpenAPI contracts. For anything beyond a small table set, the review and modernization cost can outweigh the boilerplate savings, especially past roughly 50 tables.