- How do I install Eloquent Schema in a Laravel 12 project?
- Run `composer require visualbuilder/eloquent-schema` and publish the config with `php artisan vendor:publish --tag=eloquent-schema-config`. No additional setup is needed for basic schema discovery.
- Does this package work with Laravel 11 or 12 only?
- Yes, it’s designed for Laravel 11/12 with PHP 8.2+. It leverages Laravel’s service container and MCP ecosystem, so it won’t work on older versions without modifications.
- Can I use this without Laravel Boost or MCP tools?
- Absolutely. The core schema discovery and extraction services work independently. MCP tools (like `list-models`) require Laravel Boost, but you can access schemas programmatically via `ModelDiscoveryService`.
- How does schema caching work, and when should I clear it?
- Schemas are cached for a configurable TTL (default: 1 hour). Clear the cache manually with `php artisan eloquent-schema:clear` after model changes or automate it via post-migration hooks. Avoid disabling caching for large apps.
- Will this break existing Eloquent models or migrations?
- No, the package uses reflection and introspection—it never modifies your models or migrations. Schema extraction is non-intrusive and won’t interfere with existing functionality.
- Can I exclude specific vendor packages (e.g., Spatie) from discovery?
- Yes, use the `excluded_models` config array to blacklist specific classes or exclude entire vendor packages. Alternatively, whitelist packages in `included_packages` to reduce noise.
- What’s the performance impact of deep relationship introspection?
- Default `max_depth=2` balances speed and completeness. Depth >3 can consume significant memory. For large apps, start with shallow discovery and incrementally increase depth if needed.
- How do I integrate this with a custom AI assistant or LLM?
- Use the `ModelSchemaService` to fetch schemas programmatically or expose them via MCP tools if using Laravel Boost. For LLMs, pass the cached JSON schema to reduce token usage and improve query accuracy.
- Are there alternatives for schema introspection in Laravel?
- Manual tools like `php artisan model:schema` or packages like `spatie/laravel-model-stats` exist, but they lack MCP integration and vendor package support. This package is optimized for AI tooling and Laravel Boost ecosystems.
- How do I test schema discovery in a CI pipeline?
- Run `php artisan eloquent-schema:discover` in CI to validate model discovery. For MCP tools, test with `php artisan mcp:list-models`. Cache invalidation can be tested by toggling `cache_ttl` to 0 in config.