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 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

Technical Evaluation

Architecture fit. This is a build-time/dev-time codegen tool, not a runtime dependency. It sits in require-dev, exposes an Artisan command that introspects an existing database schema and renders Eloquent model classes from Blade templates. For us that's a clean fit: zero production surface area, no middleware, no service container hooks beyond package auto-discovery, no background workers. The blast radius is limited to the files it writes, and those files are committed and reviewable before they ever reach production.

Integration feasibility. Low. Standard Laravel package shape (service provider + publishable config + console command). Install is a one-line composer command, config is tunable (namespace, output path, base class, relation detection, naming strategy), and templates are Blade files we can override. Any Laravel engineer can read the command output and understand what happened. The main unknowns are our DB engine/version and how faithfully it maps exotic column types.

Technical risk.

  • Generated code quality: relations are inferred heuristically from foreign keys and naming conventions. Composite keys, morph relations, pivot tables, and non-standard FK naming are classic failure points.
  • Destructive overwrite: codegen tools that write into app/Models can clobber hand-edited models. We must verify default behavior is "skip existing" or run it into a scratch namespace first.
  • Schema drift: re-running against a changing schema creates git churn and review fatigue unless scoped tightly.
  • Abandonment / maintenance: 91 stars, 0 dependents on Packagist, single maintainer, low "opportunity" score (2.29). This is a convenience tool, not a strategic dependency — treat it as disposable.
  • Framework coupling: it must stay in lockstep with our Laravel and PHP versions. A Laravel major upgrade can break it, and there's no vendor SLA to lean on.

Key questions for the spike.

  1. Does it support our exact DB engine and version (e.g. MySQL 8, PostgreSQL 15/16)? Any DBAL/Doctrine dependency that Laravel 11+ has deprecated?
  2. What's the supported Laravel / PHP version matrix, and does it match ours today and on our next upgrade?
  3. How does it handle: composite primary keys, enums, JSON/JSONB, unsigned bigints, spatial types, UUIDs, and timestamp conventions?
  4. Does it respect or allow override of our base model, traits (HasFactory, SoftDeletes), cast conventions, and docblock style?
  5. Does it support a dry-run / target-directory / skip-existing mode, and is output deterministic (stable ordering) so CI diffs are meaningful?
  6. Does it handle multiple DB connections and schema-qualified tables?
  7. Is there a mechanism to regenerate incrementally without rewriting untouched models?
  8. What does a generated model look like for a representative 15-table slice of our schema — do we accept it as-is, or is it 80% rewritten?

Integration Approach

Stack fit. Appropriate for any Laravel 9+ / PHP 8.1+ codebase. It's engine-agnostic in intent but DB-driver-sensitive in practice — confirm against the driver we actually run. Best value when we have a schema but not models: legacy DB modernization, read-only replicas we're fronting with an API, or a database-first team that designs in SQL rather than migrations.

Migration path (three scenarios).

  • Greenfield against an existing schema: run once, commit everything, hand-tune relations and casts.
  • Legacy modernization: generate into app/Models/Generated (or a scratch branch), review the diff against the current hand-written models, and merge selectively. Never generate straight over a living app/Models.
  • Narrow module adoption: use it only for the tables in the module being modernized, keep the rest untouched. Lowest risk, easiest to reverse.

Compatibility checks before committing.

  • Composer constraint vs. our Laravel and PHP versions.
  • DB driver support for our engine/version and connection setup (SSL, read replicas, schema prefixes).
  • Collision handling with an existing base model class, global scopes, traits, and our Pint/PSR-12 style rules.
  • Whether our CI can run it (needs a live/staging DB; not a pure-static tool).

Sequencing.

  1. Spike (0.5–1 day). Branch, install as dev dependency, point at a staging DB, generate into a throwaway directory. No config, no templates — just look at the raw output.
  2. Evaluate output on 10–20 representative tables. Score hand-edit effort. If >50% of generated lines need rewriting, stop — the tool isn't earning its keep.
  3. Publish and tune config, then customize Blade templates to emit our base class, traits, casts, docblocks, and Pint-clean formatting.
  4. Establish the workflow: target directory, skip-existing policy, a documented command invocation, and a reviewer checklist (FK correctness, guarded/fillable, cast coverage).
  5. Roll out per module, module by module, with human review on every generated file that lands.
  6. Optional: drift check in CI — regenerate to a temp dir, diff -r against committed models, fail the build on unexplained drift. Only after the workflow is stable.
  7. Decide fate: keep as a dev tool, or remove it entirely once bootstrapping is done. Given the low dependents count, removing it after use is a legitimate and low-cost exit.

Operational Impact

Maintenance. Near-zero production maintenance (no runtime component). Ongoing cost is a dev-dependency bump on each Laravel/PHP upgrade plus periodic template upkeep as our conventions evolve. Expect to own the templates ourselves; upstream won't follow our style.

Support. No commercial support, no meaningful downstream ecosystem to lean on, single maintainer. Budget for the possibility of fork-and-patch — the templates and config are ours anyway, so a fork is a small lift. Assign a named internal owner (backend platform or chapter lead) so it doesn't become orphaned.

Scaling. Generation cost is linear in table count and runs in seconds to low minutes even on wide schemas, so it scales fine as a one-shot or on-demand tool. It does not scale as an always-on process; if we turn it into a CI drift gate, we take on the cost of keeping generated output in sync with every schema change, which can become noisy.

Failure modes and mitigations.

  • Wrong inferred relations → silent, insidious data-access bugs. Mitigation: mandatory human review of relations; integration tests on the generated relations.
  • Overwrite of hand-edited models → irreversible local loss. Mitigation: generate to a scratch namespace by default; require an explicit flag to write into app/Models; rely on git for recovery.
  • Schema drift churn → review fatigue. Mitigation: scope runs to a module; don't wire to CI until stable.
  • Unsupported column types → missing casts and silent coercion (e.g. JSON, enums, decimals). Mitigation: type-coverage audit on a representative slice.
  • Framework upgrade breakage → command fails or emits invalid code. Mitigation: pin the package version, include it in upgrade rehearsals, and keep a documented removal path.
  • Package abandonment → frozen compatibility. Mitigation: fork-and-vendor is cheap; templates are ours.

Ramp-up. ~1–2 hours for an experienced Laravel engineer to spike and evaluate; ~1 day to establish the tuned workflow plus a short README (how to run, how to override templates, which tables are excluded, the review checklist). No new conceptual knowledge needed beyond Blade and Eloquent conventions, both of which our team already has.

Bottom line for the TPM view. A tactical accelerator, not a platform bet. Adopt it as a dev-only bootstrap tool with template ownership and a strict "generate to scratch, review, merge" policy, expect to fork or discard it, and don't let it become a CI gate until the workflow has proven itself over a couple of schema changes.

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.
pharaonic/laravel-notification-dependencies
beautinow/translug
dev-brainiac/bot-cloaked
octoberrain/html
octoberrain/extension
octoberrain/exception
octoberrain/contracts
frankyso/ipaymu
3mdikram/worldmoneywords
snowsoft/config
itmosoft/laravel-subscriptions
larva/laravel-ai-qwen
adachsoft/api-version-bundle
cgv/localized-resource
noith/settings
kda/laravel-package
kda/filament-dynamic-navigation
bypersoft/signbox
pairus/product-data
fayne/laravel-filament-cms-core