Skip to content

Send Twig, YAML and XML documents to PHPantom - #155

Open
giuseppe-esposito-87 wants to merge 2 commits into
zed-extensions:mainfrom
giuseppe-esposito-87:feat/phpantom-twig-yaml-xml
Open

giuseppe-esposito-87 wants to merge 2 commits into
zed-extensions:mainfrom
giuseppe-esposito-87:feat/phpantom-twig-yaml-xml

Conversation

@giuseppe-esposito-87

Copy link
Copy Markdown

🤖 This was written by an AI agent on behalf of @giuseppe-esposito-87 (claude-code/claude-opus-5-5).

Lets PHPantom serve Twig templates and YAML and XML configuration files, as the VS Code extension already does. PHPantom answers completion, go to definition, references and rename for the names a PHP project writes in those files: Symfony and Drupal services, routes, templates and translation keys.

  • Added, not replacing. The files keep their language, and the Twig, YAML and XML extensions keep serving them.
  • Opt-in. The three languages are listed in opt_in_languages, so PHPantom never starts for them unless a user enables it, and a project without PHP is unaffected. Zed versions before 1.24 ignore that key.

To enable it, add PHPantom to the language, ideally in a PHP project's .zed/settings.json:

{
  "languages": {
    "YAML": { "language_servers": ["phpantom", "..."] },
    "Twig": { "language_servers": ["phpantom", "..."] }
  }
}

Tested as a dev extension in Zed 1.27 on a Drupal 11 site, with the PHPantom Drupal support from PHPantom-dev/phpantom_lsp#535: go to definition from a routing file to the controller, from a menu link and a Twig path() to the route, and references from a route to its PHP, YAML and Twig uses. Formatting a YAML file still goes to the YAML extension.

PHPantom answers completion, go-to-definition, references and rename for the names it reads in Twig templates and in YAML and XML configuration (services, routes, templates, translations). The files keep their language; the Twig, YAML and XML extensions keep serving them.

Assisted-by: claude-code/claude-opus-5-5
Zed's defaults set no language_servers for these languages, so without this every user of the extension would get PHPantom on any YAML, Twig or XML file, in projects without PHP too. Users enable it per language, ideally in the project settings of a PHP project. Zed versions before 1.24 ignore opt_in_languages.

Assisted-by: claude-code/claude-opus-5-5
@cla-bot

cla-bot Bot commented Nov 5, 2026

Copy link
Copy Markdown

We require contributors to sign our Contributor License Agreement, and we don't have @giuseppe-esposito-87 on file. You can sign our CLA at https://zed.dev/cla. Once you've signed, post a comment here that says '@cla-bot check'.

@giuseppe-esposito-87

Copy link
Copy Markdown
Author

@cla-bot check

@cla-bot cla-bot Bot added the cla-signed label Nov 5, 2026
@cla-bot

cla-bot Bot commented Nov 5, 2026

Copy link
Copy Markdown

The cla-bot has been summoned, and re-checked this pull request!

@emilmolner

Copy link
Copy Markdown

Tested this on Zed 1.29.3 as a dev extension (PHPantom 1.0.0), on Symfony 7.4 projects, with PHPantom attached to YAML, XML and Twig:

YAML (config/services.yaml)

  • go to definition from class: and FQCN service keys to the PHP class
  • '%parameter%' to its declaration under parameters:
  • '@service' to the service definition
  • a method in calls: to the PHP method
  • hover on classes and parameters
  • find references on a parameter, across YAML and PHP ($this->getParameter('...')), and back from PHP to the YAML declaration

XML (Doctrine *.orm.xml mappings)

  • <entity name="...">, target-entity and enum-type go to the PHP class / enum
  • hover on the entity class

Twig

  • {% extends '...' %} and render('...') in PHP go to the template
  • {% block %} goes to the parent template's block
  • filters go to their PHP implementation, with hover signatures

Without this change none of it is reachable in Zed, since the extension only attaches PHPantom to PHP and Blade. Would be great to get this merged 🙏

Note: my build registered the languages without opt_in_languages and I enabled nothing in settings, so I haven't exercised the opt-in path itself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants