Fabien Potencier has announced Symfony Language Tools. It is an official LSP server that helps editors understand Symfony code.

Symfony apps use strings for many important parts of the framework. As the announcement explains:

A Symfony application is full of strings that mean something: route names, service ids, template paths, translation keys, environment variables. But to most editors, they mean nothing.

For example, an editor may not catch the typo in redirectToRoute('order_confirmaton'). A developer might not find it until that code runs. PhpStorm has offered Symfony support for years, but developers using other editors have had fewer options.

What It Understands

The server works across PHP, Twig, and YAML files, and covers:

  • Route names and service ids
  • Template paths and translation keys
  • Environment variables and bundle configuration
  • Messenger, events, Security, forms, and validation
  • Serializer metadata
  • AssetMapper, Stimulus, and Live Components
  • Doctrine

For these parts of Symfony, the server can offer code completion, hover details, go-to-definition, reference search, renaming, error checks, quick fixes, and code lenses.

It does not replace your PHP language server. The two run side by side, with Symfony Language Tools handling framework-specific details.

How It Stays Accurate

Many editor tools try to work out what a string means by reading source files. Symfony Language Tools can also use data from the running framework:

The server does not guess from your source files alone; in a trusted workspace, it boots your kernel in debug mode to read the compiled container, the effective router and other runtime metadata.

In a trusted project, the server can see the services that are registered and the routes that are loaded. It can also see changes made by compiler passes. This gives the editor a more accurate view of the app.

Getting Started

The VS Code extension includes the server for your platform. You can install it with:

code --install-extension symfony.language-tools

For Neovim, install symfony-lsp from a release or through Mason. Then enable it:

vim.lsp.enable('symfony_lsp')

Other editors with LSP support can use the builds for Linux, macOS, and Windows. After you extract the files, keep symfony-lsp and symfony-lsp-tree-sitter in the same folder. You can check the install with ./symfony-lsp --version.

You need a maintained Symfony version, installed Composer packages, and a PHP binary that works with the app. The project uses the MIT license.

The Project Is Still in Beta

Potencier warns that the project is still experimental:

A word of caution: this is a beta, and an experimental one. I'm releasing it early because real-world usage is what moves a beta forward.

The announcement also explains how the project was built. AI models wrote and reviewed most of the code. Potencier directed the design, chose the scope of each feature, and made the final decisions. The project includes tests and performance benchmarks. It was also tested on symfony.com and other *.symfony.com sites.

Read More

Visit the symfony/language-tools repository for setup guides, settings, and the full feature list. Potencier's announcement shares more about the project and how it was built. Bug reports and other feedback can be posted on GitHub.