Auto-detect Symfony configuration JSON Schemas in PhpStorm
Symfony ships generated JSON Schemas for its configuration files. It would be very helpful if PhpStorm detected and applied these schemas automatically, without the user having to register a manual JSON Schema mapping.
Background
The upcoming Symfony 8.2 release generates a JSON Schema for the application configuration during debug container compilation (feature merged in https://github.com/symfony/symfony/pull/62125):
- config/schema.json: a JSON Schema that merges the configuration trees of every installed bundle. It validates and autocompletes the YAML files stored under config/packages/ (including the config/packages/<env>/ sub-directories and the when@<env> conditional sections).
This file is committed to the repository, so it is always available inside the project. Today users have to add a manual mapping through Settings > Languages & Frameworks > Schemas and DTDs > JSON Schema Mappings, pointing config/schema.json to the pattern config/**/*.yaml. Editors backed by yaml-language-server (VS Code, Neovim) can rely on an inline modeline comment, but that requires editing each file.
JSON Schemas for services and routing configuration have already existed since Symfony 7.4, so this request also covers those existing schemas.
Request
When a config/schema.json file is present at the project root, please automatically map it to the application configuration files:
- config/services.yaml
- config/packages/*.yaml
- config/packages/**/*.yaml
so that autocompletion and validation work out of the box.
Routing schema
Routing configuration follows a different schema and lives in separate files:
- config/routes.yaml
- config/routes/*.yaml
The matching JSON Schema has been bundled with the Routing component since Symfony 7.4, at:
src/Symfony/Component/Routing/Loader/schema/routing.schema.json
(https://github.com/symfony/symfony/blob/7.4/src/Symfony/Component/Routing/Loader/schema/routing.schema.json)
Please sign in to leave a comment.
Hello,
I was wondering if you could submit a corresponding feature request on the YouTrack issue tracker:
https://youtrack.jetbrains.com/newIssue
I have quickly checked it for any existing similar tickets, but was not able to find anything.
Sure, I created https://youtrack.jetbrains.com/issue/WI-85802/Auto-detect-Symfony-configuration-JSON-Schemas-in-PhpStorm