docs(laravel): document booting without a database connection#2294
Open
soyuka wants to merge 1 commit into
Open
docs(laravel): document booting without a database connection#2294soyuka wants to merge 1 commit into
soyuka wants to merge 1 commit into
Conversation
API Platform reads Eloquent metadata from the live database schema while building resource metadata at boot (route registration, OpenAPI, caching). The app therefore cannot boot when no migrated database is reachable, which breaks Docker image builds, `composer install` (package:discover) and static analysis (Larastan) in CI. Add a section to the Laravel guide explaining the cause and the available workarounds: using a migrated SQLite database at build time, deferring metadata commands to the container entrypoint, and provisioning a database for static analysis. Refs api-platform/core#8131
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds a Booting Without a Database Connection section to the Laravel guide (
laravel/index.md).Why
To expose an Eloquent model, API Platform reads its metadata (columns, types, relations, identifiers) directly from the database schema. This introspection runs while resource metadata is built, which happens at boot during route registration (
routes/api.phpiterates every resource) →ModelMetadata::getAttributes()→$schema->getColumns()→ a live DB query.Consequence: the app cannot boot when no migrated database is reachable. This bites in common setups:
docker build(DB service not running);composer install→@php artisan package:discover;Reported in api-platform/core#8131.
What the section documents
composer install --no-scripts);Notes / follow-up
No code change. The cleaner long-term fix discussed in the issue — a dedicated artisan command that dumps computed metadata to a file-based store (committable / bakeable into the image) — does not exist in
core/src/Laravel/Consoleyet.api-platform:installis not the right place for it (only publishes config/assets, runs without models/DB). When that command lands, this section should point to it.Refs api-platform/core#8131