- How do I install krlove/code-generator in Laravel?
- Install it as a development-only Composer dependency with composer require --dev krlove/code-generator. It is intended for local development or CI scaffolding, not as a runtime production dependency. After installation, run the package's Artisan command against a configured database connection and review the generated models before committing them to app/Models.
- Does krlove/code-generator support Laravel 10 or 11?
- There are no Laravel 10 or 11 compatibility guarantees because the package is archived and its last release was in 2022. You must validate its Composer constraints, Artisan command registration, and Doctrine DBAL dependency against your exact Laravel and PHP versions. Run a small proof of concept before relying on it for a larger schema.
- How does krlove/code-generator generate Eloquent models from database tables?
- It introspects an existing database schema through a configured Laravel connection and produces Eloquent model classes from the tables it finds. Generated output includes model naming, fillable fields, casts, and relationship inference based on the schema. Because inference can be imperfect, you should review and standardize the generated code before adopting it.
- Can I customize the generated model templates?
- Yes, the package supports customizable templates so generated models can follow your application's conventions. This is useful for adjusting namespaces, base classes, traits, docblocks, and relationship formatting. If the archived package cannot meet your needs, forking it and maintaining an internal template set is a practical fallback.
- Does krlove/code-generator generate relationships, casts, and fillable fields?
- It aims to generate relationships, casts, and fillable fields based on the inspected schema. Foreign keys can drive relationship inference, but results may be wrong or incomplete for nonstandard naming, composite keys, or custom column types. Always diff and review generated models rather than trusting them blindly.
- Is krlove/code-generator safe to use in production?
- It should not be part of the production dependency graph. Treat it as a dev-time scaffolding tool installed with --dev and run against a read-only database replica. Generated code still requires review, and schema drift means models can become stale after database changes.
- What database drivers and column types are supported?
- Support depends on the underlying schema introspection layer and Doctrine DBAL compatibility with your database engine and Laravel version. Enums, JSON, spatial types, custom column types, and composite keys are common edge cases that may break generation or produce incorrect casts. Test against the exact schema family you plan to generate from.
- Will the Artisan command overwrite existing model files?
- Overwrite behavior depends on the package version and command options, so verify it before running against a real project. Generate into a sandbox or version-controlled branch first and inspect the diff. Back up existing models or use a separate output namespace to avoid losing manual changes.
- What are alternatives if krlove/code-generator is archived?
- You can fork the package internally, write a one-off schema introspection script, or use newer maintained generators if they fit your Laravel version. Because the package is archived with no security patches or upstream fixes, an internal fork or replacement is a reasonable long-term plan. Keep generated application code committed and the generator itself out of production.
- How do I handle custom column types or composite keys with this generator?
- Start with a representative subset of tables that includes your custom types and composite keys, then inspect whether casts, fillable fields, and relationships are generated correctly. If introspection fails, adjust templates or patch the generator in a fork. Document the runbook and batch generation so unsupported schema features are caught early.