Skip to content

Improve configuration validation #7053

Open
@kira0269

Description

@kira0269

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"

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions