- What is Laravel ModelSchema used for?
- Laravel ModelSchema is a foundational package for defining and parsing model schemas in YAML. It gives you a unified structure to describe models, fields, relations, and options, and it can inspect Eloquent models to produce database schema definitions. It supports workflows such as generating migrations, keeping models and tables in sync, and documenting your data layer from one source of truth. It also serves as the YAML engine behind Laravel Arc, Laravel TurboMaker, and future Grazulex packages.
- How do I install Laravel ModelSchema with Composer?
- Install it as a Composer package using the package name grazulex/laravel-modelschema. In a Laravel app, check whether your version auto-discovers the service provider; if not, register it as described in the repository README. After installation, review the package configuration and schema file locations before running any generation commands. Pin a version such as ^1.3.1 once you have validated it against your Laravel and PHP matrix.
- What does a ModelSchema YAML file define?
- A ModelSchema YAML file describes a model and its schema in a readable, extensible format. Based on the package overview, it can define models, fields, relations, and options in one place. That structure is what lets the package parse the schema and resolve it into generated components or database schema definitions. Treat the YAML shape as the source of truth for your model metadata and keep it under version control.
- Does Laravel ModelSchema generate migrations from my Eloquent models?
- The package is positioned around converting Eloquent model information into database schema definitions, and the blurb mentions generating migrations as a use case. In practice, ModelSchema provides the schema definition and parsing layer; migration generation is part of the generation workflow rather than a promise that every app can run one command without configuration. You should validate generated migrations in a branch and compare them with your existing database structure before applying them. Use the package generation service or supporting commands as documented in the repository.
- How are relationships handled in a Laravel ModelSchema schema?
- Relations are part of the unified schema structure the package defines, alongside models, fields, and options. The YAML schema is intended to describe those relations so the parser can resolve them consistently for generated artifacts and documentation. The exact relation types and options depend on the package documented YAML format, so check the repository examples before modeling complex relationships. For production use, test generated relation output against your existing Eloquent relations.
- Which Laravel and PHP versions does Laravel ModelSchema support?
- The provided release context does not list a specific Laravel or PHP version matrix, so you should verify the package composer.json constraints before adopting it. The v1.3.1 patch is described as a patch-level, backward-compatible change at the API surface, with no framework-version-specific constructs implied by the release note. Pin the package to ^1.3.1 in a branch and test it against your target Laravel and PHP versions. Do not assume support for a Laravel major version until the package constraints confirm it.
- Does Laravel ModelSchema modify my existing models or database?
- ModelSchema is described as a schema definition and parsing layer that resolves definitions into generated components such as models and related artifacts. That means its main job is to generate or describe code and schema data, not to silently alter your live database. Any migration or file generation should be run deliberately and reviewed in version control. Back up your database and inspect generated output before applying changes in production.
- How should I test Laravel ModelSchema output in CI?
- Run a known-good generation in CI and assert that the expected output files or fragments are present, rather than relying only on a success flag. The package returns json/yaml fragments, and v1.3.1 changed success-detection logic for logging and metrics, not the generated output or fragment shape. Diff generated output against a committed baseline to catch unexpected changes. Add your own assertions for expected components so silent partial generation does not pass the pipeline.
- What is the GenerationService fragment contract in Laravel ModelSchema?
- GenerationService is the orchestration surface, with generateAll() for a full run and generateModel() for a targeted model-level run. It returns structured json/yaml fragments, and those fragments do not include an explicit success key in the context provided. v1.3.1 only changes how success is detected for logging and metrics; it does not change service signatures or the returned fragment shape. Treat fragment presence and shape as a heuristic, not a formal API contract, unless the maintainer documents it as one.
- Is Laravel ModelSchema production-ready, and what are the alternatives?
- For production adoption, the main risks are heuristic success detection, silent partial generation, and historical metrics that are not comparable after v1.3.1. Pin ^1.3.1, wrap GenerationService in your own thin service, and assert expected output files in CI before trusting a run. The package fits Laravel-native service and Artisan command patterns, so a custom command or queued job is a reasonable integration path. Alternatives depend on your need: hand-written migrations, Laravel native model and migration tooling, or other schema-generation packages; evaluate them against the same output-contract and maintenance questions.