Repository navigation
Add Symfony LSP diagnostics to CI - #87
Merged
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## 1.14.x #87 +/- ##
===========================================
Coverage 100.00% 100.00%
Complexity 2 2
===========================================
Files 2 2
Lines 16 16
===========================================
Hits 16 16 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Run `symfony lsp:check` (https://symfony.com/blog/introducing-symfony-lsp-check-symfony-aware-diagnostics-in-your-ci) as a new "symfony-diagnostics" job so that unknown routes, services, templates, translation keys, deprecated configuration keys etc. are reported as GitHub annotations. symfony-lsp only discovers a Symfony application when its composer.json requires symfony/framework-bundle and, to boot it, needs a PSR-4 entry pointing at the kernel plus <project>/vendor/autoload.php. The test application is not a standalone Composer project, so: - tests/Application/composer.json declares the framework-bundle requirement and the PSR-4 namespace of the kernel (nothing is ever installed from this file) - tests/Application/vendor is a symlink to the root vendor directory - phpunit.xml.dist excludes tests/Application and vendor because PHPUnit follows symlinks when discovering tests - .symfony-lsp.json points symfony-lsp at tests/Application and enables translation diagnostics
framework.form.legacy_error_messages and security.enable_authenticator_manager are deprecated no-ops on Symfony 6.4.
The check belongs with the other lint steps rather than in a job of its own.
With tests/Application as the project root, symfony-lsp only analyzed the test application, not the plugin's src/Resources. It also needed a PSR-4 entry in tests/Application/composer.json and a tests/Application/vendor symlink to boot the kernel at all, plus a phpunit.xml.dist exclusion because PHPUnit followed that symlink. Analyze the repository root instead and name the kernel in .symfony-lsp.json. The root has vendor/autoload.php and the kernel is autoloadable through the root composer.json, so those workarounds are reverted. A template in src/Resources/views using a non-existent route is now reported. symfony-lsp only loads a .env file from the root it analyzes, so the kernel now boots without tests/Application/.env. The only variable that is then missing is APP_SECRET; give it a fallback like doctrine.yaml does for DATABASE_URL. symfony-lsp now keeps its cache in the root var/, so ignore it.
loevgaard
force-pushed
the
symfony-lsp-check-1.14.x
branch
from
October 19, 2026 11:33
76932ff to
b3f36a2
Compare
loevgaard
commented
Oct 19, 2026
This was referenced Oct 19, 2026
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.
Integrates symfony lsp:check into the build workflow as a step of the
coding-standardsjob (PHP 8.1, highest deps), next to the YAML and Twig lint steps. It runssymfony lsp:check --format=github, so unknown routes/services/templates/translation keys, deprecated config keys etc. show up as annotations on pull requests.This is the 1.14.x counterpart of #88. On 2.2.x the check lives in
setono/sylius-plugin'scoding-standardsaction. 1.14.x has a self-contained workflow (thesetono/sylius-pluginv2 actions target Sylius 2), so here it's a step inbuild.yaml, with the Symfony CLI from setup-php'stools: symfony.Configuration
.symfony-lsp.jsonpoints symfony-lsp at the repository root and names the test application's kernel, as #88 does on 2.2.x:{ "version": 1, "projectRoots": ["."], "kernel": "Acme\\SyliusExamplePlugin\\Tests\\Application\\Kernel", "translationDiagnostics": true }vendor/autoload.php, which symfony-lsp's bridge hard-codes as<project>/vendor/autoload.php.composer.json.src/Resourcesis analyzed, not only the test application.APP_SECRETfallback: symfony-lsp only loads a.envfile from the root it analyzes, so it boots the kernel withouttests/Application/.env.APP_SECRETis the only variable that's then missing (checked by leaving each one out); without it the analysis is incomplete (exit 12).framework.yamlnow gives it a fallback, the same waydoctrine.yamlalready does forDATABASE_URL. The fallback only applies when.envisn't loaded.<project>/var/symfony-lsp, so/var/is now ignored, in a separate block from/node_modules/, which Remove the root node_modules symlink and point badges at 1.14.x #96 changes.CLAUDE.mddocuments the command.Changed since the first version
The first version used
projectRoots: ["tests/Application"]. That needed three workarounds just to boot the kernel:symfony/framework-bundlerequirement and a PSR-4 entry intests/Application/composer.json;tests/Application/vendorsymlink;phpunit.xml.distexclusion, because PHPUnit followed that symlink.It also left the plugin's own templates unchecked. All three are reverted. The branch is also rebased onto the current 1.14.x.
Deprecated config keys
The second commit removes the two deprecated config keys the check flagged in the test application (
framework.form.legacy_error_messages,security.enable_authenticator_manager). Both are no-ops on Symfony 6.4.Verification
Run locally on PHP 8.1, as in CI, with symfony-lsp 0.24.0, the version the Symfony CLI in CI downloads:
symfony-lsp check --format=githubanalyzes project.with runtime metadata, 0 diagnostics, exit code 0.{{ path('nonexistent_route') }}insrc/Resources/views/is reported asroute.not_found, exit code 10.vendor/bin/phpunit(4 tests),bin/console lint:container,lint:yamland ECS pass.Running the check locally requires the Symfony CLI 5.20 or newer (
symfony lsp:check), or the standalonesymfony-lspbinary from https://github.com/symfony/language-tools/releases.