Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Eloquent Model Generator

Eloquent Model Generator Laravel Package

pepijnolivier/eloquent-model-generator

Generate Eloquent model classes directly from your database tables. This Laravel package inspects your schema and scaffolds models with fillable fields, relationships, casts, and docblocks, cutting boilerplate and speeding up development.

View on GitHub
Deep Wiki
Context7

Eloquent Model Generator

Frequently asked questions about Eloquent Model Generator
What does pepijnolivier/eloquent-model-generator do?
It is a Laravel Composer package that auto-generates Eloquent model classes from the tables in your application's database. Instead of writing boilerplate models by hand, you run the package's generator and it creates model files based on your schema. It is intended for Laravel projects that already have a database structure and want matching Eloquent models.
How do I install eloquent-model-generator in a Laravel app?
Install it with Composer using composer require pepijnolivier/eloquent-model-generator. If you only use it locally for code generation, consider installing it as a dev dependency. After installation, check the package README for any service provider registration or publishable configuration steps required by your Laravel version.
Which Laravel versions does this model generator support?
Compatibility depends on the package's Composer constraints, so check its composer.json and README for the supported Illuminate and PHP versions. Laravel packages often support a range of major versions, but you should verify before adding it to an existing app. If you are on an older or very new Laravel release, test installation in a branch first.
How do I generate Eloquent models from an existing database?
Configure your Laravel database connection to point at the schema you want to inspect, then run the model generator command provided by the package. The exact command signature is documented in the README. The generator reads your tables and writes corresponding Eloquent model classes into your application.
Can it detect relationships such as belongsTo and hasMany?
Relationship generation depends on the package's schema inspection behavior and your database foreign key definitions. If your tables define foreign keys, the generator may be able to infer common relationships, but you should always review the generated models. Complex or polymorphic relationships often still require manual adjustments.
Will eloquent-model-generator overwrite my existing model files?
Code generators can overwrite files with the same class name, so treat generated output carefully. Commit your current models or work on a clean branch before running the generator. Check the package options for overwrite, force, or skip-existing behavior before using it on a project with hand-written models.
How do I exclude tables or customize model naming?
Look for publishable configuration or command options that let you exclude tables, set namespaces, or adjust naming conventions. The available settings are defined by the package and should be listed in its README. If the package does not expose a specific option, you may need to generate first and then clean up or customize the output manually.
Can I run the model generator in CI or automated workflows?
You can run it in CI if your pipeline has a database schema available and the generated files are deterministic for your team. It is usually better to generate models locally and commit them, then use CI to verify they match the expected schema. Avoid generating files during production deploys unless you have a clear review and rollback process.
Is it safe to run this package in production?
The package is a development-time code generation tool, not a runtime feature, so it generally should not run in production. Running it writes PHP model files and can overwrite existing code if misconfigured. Use it in local or staging environments, review the diff, and deploy the generated models through your normal release process.
What are alternatives to this Eloquent model generator?
Alternatives include manually writing models, using schema-to-code tools, or packages such as reliese/laravel that also generate Laravel models from database tables. The best choice depends on your need for relationship inference, custom templates, and Laravel version support. Compare the generated output and maintenance activity before standardizing on one generator.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
middlewares/firewall
qubiqx/montapacking
nyoncode/laravel-package-console
pnscripts/filament-broadquill-lite
pnscripts/laravel-sentfold-lite
vleap/mx-sdk-laravel-internal
twidpay/utils
htetmyathlaing/scout-elasticsearch-driver
artisan-toolbox/front-awesome
ls/client-assistant
users-au/laravel-client
cgv/localized-resource
noith/settings
kda/laravel-package
kda/filament-dynamic-navigation
bypersoft/signbox
pairus/product-data
fayne/laravel-filament-cms-core
nodisrupt/laravel-agent
sierratecnologia/media-manager