core icon indicating copy to clipboard operation
core copied to clipboard

Improve configuration validation

Open kira0269 opened this issue 10 months ago • 1 comments

Description
Bundle configuration does not check if required package is installed before configuring associated services.

Example
In ApiPlatform\Symfony\Bundle\DependencyInjection\ApiPlatformExtension.php, we will configure the availble formats. If we try to configure the format jsonhal:

api_platform:
    title: Hello API Platform
    version: 1.0.0
    formats:
        jsonld: [ "application/ld+json" ]
        jsonhal: [ "application/hal+json" ]

An exception is thrown saying "Invalid service "api_platform.hal.normalizer.entrypoint": class "ApiPlatform\Hal\Serializer\EntrypointNormalizer" does not exist".

Proposal In ApiPlatform\Symfony\Bundle\DependencyInjection\ApiPlatformExtension.php, check for required libraries associated with specific configuration. In the previous example, error message could be "Trying to configure jsonhal format, but required package api-platform/json-hal is not installed"

kira0269 avatar Mar 26 '25 13:03 kira0269

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar May 25 '25 14:05 stale[bot]