Compass for Symfony
Completion, go to definition, references, CodeLens and diagnostics for Symfony projects in VS Code:
routes, Twig, services, translations, Doctrine, forms, security, assets and events.
Unofficial. Compass for Symfony is a community extension. It is not affiliated with or endorsed
by Symfony SAS. "Symfony" is a trademark of Symfony SAS, used here only to describe the framework
the extension supports.
Compass brings to VS Code what the Symfony Plugin brings to PhpStorm: it links PHP, Twig and YAML
through the things Symfony wires together by name.
It works alongside a PHP extension such as Intelephense, which keeps handling generic PHP
(types, classes, methods). Compass only deals with what is specific to Symfony.

Features
Routes
- Completion of route names in
path(), url(), redirectToRoute(), generateUrl()…, with path and methods.
- Go to definition (the
#[Route] attribute, YAML or XML declaration), hover, Find All References.
- Completion of route parameters; diagnostics for unknown routes and missing parameters.
- CodeLens above controller actions: methods, path and number of usages.

Twig
- Template names in PHP and Twig (
render(), #[Template], include, extends, embed,
@Bundle/ namespaces): completion, go to definition, diagnostics, and a quick fix to create a missing template.
- Parent blocks in
{% block %}, and variables passed by controllers, include … with, set, for and macros.
- Filters, functions and tests from Twig, bundles and your own extensions (classic or attribute-based),
with their signatures.
- Symfony UX Twig components:
<twig:Alert>, component('…'), {% component %} and their props.

Services, parameters and translations
- Service IDs and
%parameters% in YAML configuration and #[Autowire]: completion, definition,
hover, diagnostics.
- Translation keys and domains (
trans(), |trans, {% trans %}, t()): completion with the
translated text, definition, hover, diagnostics, and a quick fix to add a missing key.
- Entity fields in
findBy() criteria, QueryBuilder DQL (->andWhere('p.name = :n')) and full DQL
(createQuery('SELECT p FROM App\Entity\Product p …')): completion, definition, unknown-field diagnostics.
- Form type options (
->add('name', TextType::class, ['label' => …])) and field names from data_class.

Other Symfony contexts
%env(…)% variables from your .env files, with their values and env var processors.
- Security roles in
is_granted(), #[IsGranted] and security.yaml (role hierarchy, voters).
asset() paths (public/ and AssetMapper) and Stimulus controllers (stimulus_controller(), data-controller).
- Event names in
#[AsEventListener], getSubscribedEvents() and service tags, with their listeners.

Requirements
- VS Code 1.91 or later.
- A Symfony 6.4 or 7.x project (PHP 8.2+). Routes may be declared with attributes, YAML or XML.
- Optional: PHP (locally or in Docker) to run
bin/console. Without it, Compass relies on static analysis only.
How it works
Compass runs a language server that builds in-memory indexes of your project:
| Data |
Source |
| Services, aliases, tags, parameters, event listeners |
The compiled container (var/cache/dev/*DebugContainer.xml), completed by a static analysis of config/ |
| Routes |
bin/console debug:router, plus #[Route] attributes, YAML and XML |
| Templates |
templates/, twig.paths and bundle templates |
| Translations |
XLIFF, YAML and JSON catalogues of the application, bundles and components |
| Doctrine entities, forms, Twig extensions… |
Parsed from your sources and vendor/ with tree-sitter |
Indexing runs in the background and is updated as files change.
Symfony: Refresh index runs cache:warmup and rebuilds everything.
Symfony: Show index status prints what was indexed.
Workspace Trust
bin/console executes your project's PHP code. It only runs in trusted workspaces.
In restricted mode, Compass still works through static analysis.
Docker
// .vscode/settings.json
{
"symfony.executor": "docker",
"symfony.dockerService": "php", // service name in docker-compose.yml
"symfony.dockerWorkdir": "/var/www/html" // project root inside the container
}
Paths reported by the container are mapped back to your workspace through symfony.dockerWorkdir.
Settings
| Setting |
Default |
Description |
symfony.projectRoot |
"" |
Project root (folder of composer.json), relative to the workspace folder. Empty: auto-detection, including sub-folders of a monorepo. |
symfony.runConsoleOnStartup |
true |
Run bin/console debug:router at startup (trusted workspaces only). |
symfony.consolePath |
bin/console |
Path to the Symfony console. |
symfony.executor |
local |
local or docker. |
symfony.phpPath |
php |
PHP binary used by the local executor. |
symfony.dockerService |
php |
Docker Compose service used by the docker executor. |
symfony.dockerWorkdir |
"" |
Project root inside the container. |
symfony.containerXmlPath |
"" |
Compiled container XML. Empty: the most recent var/cache/dev/*DebugContainer.xml. |
symfony.diagnostics.templates |
true |
Report unknown templates. |
symfony.diagnostics.routes |
true |
Report unknown routes and missing route parameters. |
symfony.diagnostics.translations |
true |
Report translations missing from the default locale. |
symfony.diagnostics.services |
true |
Report unknown services and parameters in config/ YAML. |
symfony.diagnostics.doctrine |
true |
Report unknown entity fields. |
symfony.codeLens |
true |
Show CodeLens on controller actions and templates. |
Known limitations
- Only static values are understood: a template, route or key built from variables is ignored.
- Variables are not propagated from child templates or from templates that include the current one.
- Diagnostics that need a complete picture (unknown routes or services) are only reported when the
corresponding index is complete, for example when the compiled container is available.
- Messages and diagnostics are currently in French.
Development
The repository is an npm workspace:
packages/server: the language server. It has no dependency on the VS Code API and can be reused by other editors.
packages/vscode: the VS Code client.
npm install
npm run build # bundles the server and the client (esbuild)
npm run typecheck
npm test # vitest, against fixtures/symfony-app (no PHP or Composer needed)
npm run package # builds compass-symfony.vsix
npm run fixture:setup installs the fixture's Composer dependencies, warms its cache and regenerates
the frozen test data. It needs PHP 8.2+ and Composer, and is only required to test against a real
vendor/ or to update the test data.
In VS Code, the Extension Symfony (fixture) launch configuration opens the fixture with the extension loaded.
License
MIT
| |