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

Laravel Model Info Laravel Package

spatie/laravel-model-info

Inspect Laravel Eloquent models to discover their file name, table name, attributes (name/type) and relations (name/type/related model). Also includes a ModelFinder to automatically locate all models in your application.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Developer Tooling & Productivity: Accelerates development by providing programmatic access to model metadata (e.g., attributes, relations, table names), reducing manual inspection of model files.
  • Schema/Contract Validation: Enables automated validation of model structures (e.g., ensuring required fields exist or relations are correctly defined) during CI/CD pipelines or pre-deployment checks.
  • Dynamic Documentation Generation: Powers auto-generated API/docs (e.g., Swagger/OpenAPI) or admin panels by extracting model metadata to populate schemas or UI forms dynamically.
  • Migration & Refactoring Safety: Supports safe database migrations or refactoring by cross-referencing model definitions with existing database schemas (e.g., detecting unused columns or missing indexes).
  • Build vs. Buy: Buy for teams needing lightweight, maintainable metadata access without reinventing wheel. Build only if requiring deeply customizable or performance-critical solutions (e.g., real-time schema introspection for large-scale systems).
  • Use Cases:
    • Internal Tools: Build admin dashboards or data exploration tools that adapt to model changes without hardcoding.
    • Testing: Generate test data or validate model configurations in unit/integration tests.
    • Legacy System Modernization: Audit existing models to identify inconsistencies or deprecated patterns.

When to Consider This Package

  • Adopt When:

    • Your Laravel app has 50+ models and developers frequently need to inspect model structures (e.g., for debugging, onboarding, or tooling).
    • You’re building self-documenting systems (e.g., APIs, admin panels) where model metadata drives UI or validation logic.
    • Your team lacks a centralized schema registry (e.g., no dedicated DB schema tool like Prisma or TypeORM).
    • You need lightweight runtime introspection (e.g., for dynamic form generation) without heavy ORM dependencies.
  • Look Elsewhere If:

    • You require real-time schema changes (e.g., hot-reloading) or multi-database support (this package is Laravel-specific).
    • Your models are highly dynamic (e.g., generated via codegen) or use non-standard Laravel conventions (e.g., custom table name resolvers).
    • You need performance-critical introspection (e.g., for high-frequency queries; this package reflects at runtime).
    • Your stack includes non-Laravel PHP or requires cross-language compatibility (e.g., for shared schemas with Node.js/Python).

How to Pitch It (Stakeholders)

For Executives: *"This package lets us automate model metadata access in Laravel, cutting time spent manually auditing schemas by ~30%. It’s a lightweight, MIT-licensed tool that enables:

  • Faster development: Dynamically generate forms, docs, or tests from model definitions.
  • Reduced technical debt: Catch schema mismatches early (e.g., missing columns in migrations).
  • Scalable tooling: Build self-service admin panels or APIs without hardcoding model logic. Think of it as ‘Laravel’s built-in schema introspection’—no extra infrastructure, just instant insights into your data layer."

For Engineering: *"Spatie’s laravel-model-info gives us programmatic access to model attributes, relations, and table names at runtime. Key wins:

  • Replace manual dd() debugging: Get model structure via $modelInfo->attributes->whereType('string') instead of grepping files.
  • CI/CD hooks: Validate model contracts (e.g., ‘Does User have a name field?’) in pipelines.
  • Dynamic UI: Power admin panels or APIs with auto-generated schemas (e.g., ‘Show all BelongsTo relations for this model’). Downside: Runtime reflection adds ~5ms/model (negligible for most apps). Tradeoff: zero maintenance vs. custom solutions."*
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.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport