Skip to content

fix(symfony): register property_info fallback when not provided by Symfony#7969

Open
guillaumedelre wants to merge 1 commit into
api-platform:mainfrom
guillaumedelre:fix/property-info-service-not-required
Open

fix(symfony): register property_info fallback when not provided by Symfony#7969
guillaumedelre wants to merge 1 commit into
api-platform:mainfrom
guillaumedelre:fix/property-info-service-not-required

Conversation

@guillaumedelre
Copy link
Copy Markdown
Contributor

Q A
Branch? main
Tickets Fix #7876
License MIT
Doc PR Closes api-platform/docs#2262

Summary

When symfony/framework-bundle has property_info disabled (the default on full-stack Symfony unless explicitly opted-in), the prependExtensionConfig() call in ApiPlatformExtension::prepend() can be overridden by user configuration. This results in a container compilation error:

The service "api_platform.metadata.property.name_collection_factory.property_info"
has a dependency on a non-existent service "property_info".

This was reported in #7723 and confirmed via api-platform/docs#2262, where @soyuka noted that a code-level fix was the right approach.

Fix

Add a PropertyInfoPass compiler pass (running at TYPE_BEFORE_OPTIMIZATION with priority 200, before any alias resolution) that checks whether property_info is registered in the container. If not, it registers a minimal fallback: a PropertyInfoExtractor backed by ReflectionExtractor with the standard property_info.* tags.

This ensures api_platform.property_info (aliased to property_info in api.php) always resolves, without requiring users to explicitly enable property_info in their framework configuration.

Impact on docs PR

api-platform/docs#2262 adds a troubleshooting section documenting this error as a workaround. With this fix, the root cause is resolved and that PR becomes obsolete.

@guillaumedelre
Copy link
Copy Markdown
Contributor Author

@soyuka @dunglas PR ready for review — fixes #7876 by registering a PropertyInfoPass compiler pass that provides a PropertyInfoExtractor + ReflectionExtractor fallback when property_info is absent from the container.

@soyuka
Copy link
Copy Markdown
Member

soyuka commented May 12, 2026

it looks like test failures are related

@guillaumedelre
Copy link
Copy Markdown
Contributor Author

PHPUnit failures

Fixed in the latest push. Two issues were addressed:

  1. ApiPlatformBundleTest::testBuild was missing the expectation for the new PropertyInfoPass compiler pass.
  2. The test was using Prophecy, which is no longer allowed in this project. It has been migrated to plain PHPUnit: the test now instantiates a real ContainerBuilder, calls build(), and asserts each expected compiler pass class is present in getCompilerPassConfig()->getBeforeOptimizationPasses().

Laravel E2E installation failure

This failure is unrelated to this PR. The ApiPlatformProvider references ApiPlatform\JsonLd\Serializer\ItemDenormalizer (introduced in d36c14c), but the E2E installation test installs api-platform/jsonld from the published packagist package, which does not include this class yet. The same failure is reproducible on PRs #7970 and #7971, which do not touch Laravel or JSON-LD code at all.

…mfony

When symfony/framework-bundle has property_info disabled (the default on
full-stack Symfony unless explicitly opted-in), the prependExtensionConfig
fallback in ApiPlatformExtension::prepend() can be overridden by user
configuration, resulting in "service not found" errors at container compile
time.

Add a PropertyInfoPass compiler pass that registers a minimal
PropertyInfoExtractor backed by ReflectionExtractor when the property_info
service is absent, ensuring API Platform never requires it to be explicitly
enabled.

Fixes api-platform#7876

Signed-off-by: Guillaume Delré <delre.guillaume@gmail.com>
@guillaumedelre guillaumedelre force-pushed the fix/property-info-service-not-required branch from ada0650 to 7de085f Compare May 12, 2026 14:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Property info service not present

2 participants