# Symfony Plugin Completion

**Completion** features provide context-aware suggestions for Symfony, Twig, Doctrine, services, routes, configuration, and related framework APIs.

---

## Twig default translation domains

**Feature ID:** `TwigTranslationDomainCompletion`  
**Date:** 2013-07-06  
**Feature Page:** [Twig default translation domains](https://espend.de/phpstorm/plugin/symfony#twig-translation-domain-completion)  

Completes and navigates translation domains and keys using `trans_default_domain`, including its file-wide `for _self` scope.

### Code Examples

```twig
# Default translation domain:
{% trans_default_domain 'admin' %}
{{ 'dashboard.title'|trans }}
```

```twig
# File-wide domain, including embeds:
{% trans_default_domain 'admin' for _self %}

{% embed 'panel.html.twig' %}
    {% block body %}
        {{ 'dashboard.help'|trans }}
    {% endblock %}
{% endembed %}
```

---

## Form type guessing from PHP and Doctrine

**Feature ID:** `FormTypeGuessing`  
**Date:** 2026-11-12  
**Feature Page:** [Form type guessing from PHP and Doctrine](https://espend.de/phpstorm/plugin/symfony#form-type-guessing)  

Resolves form field types from PHP property types and Doctrine mappings when no explicit form type is provided. The inferred type powers option completion, navigation and Twig form field resolution.

### Code Examples

```php
# Attribute field: IntegerType inferred from ?int:
use Symfony\Component\Form\Attribute\AsFormType;
use Symfony\Component\Form\Attribute\FormField;

#[AsFormType]
class EventData
{
    #[FormField(options: ['grouping' => true])]
    public ?int $capacity = null;
}
```

```php
# Builder field using the data class property:
// configureOptions()
$resolver->setDefaults(['data_class' => EventData::class]);

// buildForm(): IntegerType options are available without an explicit type.
$builder->add('capacity', options: ['grouping' => true]);
```

---

## UX CSS token values in completion

**Feature ID:** `UxCssTokenCompletion`  
**Date:** 2026-11-11  
**Feature Page:** [UX CSS token values in completion](https://espend.de/phpstorm/plugin/symfony#ux-css-token-completion)  

Shows resolved `symfony/ux-css` token values in the `css()` completion popup, with color swatches for color tokens.

### Code Examples

```twig
# Color and spacing token suggestions:
{{ css({color: 'blue.500', p: 'md'}) }}
```

---

## HTML translation completion and navigation

**Feature ID:** `HtmlTranslationCompletion`  
**Date:** 2026-11-12  
**Feature Page:** [HTML translation completion and navigation](https://espend.de/phpstorm/plugin/symfony#html-translation-completion)  

Completes translation keys, domains, HTML tag names and message parameters in Twig `trans_html` and PHP `HtmlTranslator::trans()`, with navigation to the translation.

### Code Examples

```yaml
# translations/auth+intl-icu.en.yaml:
auth_prompt: 'Hello {name}! <signin_link>Sign in</signin_link>'
```

```twig
# Twig HTML translation:
{{ 'auth_prompt'|trans_html(
    tags: {signin_link: {tag: 'a'}},
    arguments: {name: user.name},
    domain: 'auth'
) }}
```

```php
# PHP HtmlTranslator:
/** @var \Symfony\Component\Translation\HtmlTranslator $translator */
$translator->trans(
    id: 'auth_prompt',
    tags: ['signin_link' => ['tag' => 'a']],
    parameters: ['name' => 'Daniel'],
    domain: 'auth',
);
```

---

## ICU translation parameter completion

**Feature ID:** `TranslationParameterCompletion`  
**Date:** 2026-11-13  
**Feature Page:** [ICU translation parameter completion](https://espend.de/phpstorm/plugin/symfony#translation-parameter-completion)  

Completes argument names from `+intl-icu` messages in PHP and Twig, including unquoted Twig keys. The popup shows argument types such as `number`, `date` and `string`, plus the alternatives of `select` arguments.

Supports `trans`, `transchoice`, `trans_html`, PHP `trans()`, `TranslatableMessage` and `t()`.

### Code Examples

```yaml
# translations/notifications+intl-icu.en.yaml:
items: '{total, number} items'
invitation: '{gender, select, female {She} male {He} other {They}} invited {name}'
```

```twig
# Argument names and select information in Twig:
{{ 'items'|trans({total: 3}, 'notifications') }}
{{ 'invitation'|trans({gender: 'female', name: user.name}, 'notifications') }}
```

```php
# ICU parameters in PHP:
$translator->trans('items', ['total' => 3], 'notifications');
new \Symfony\Component\Translation\TranslatableMessage(
    'items', ['total' => 3], 'notifications'
);
```

---

## FOSJsRouting route completion and navigation

**Feature ID:** `FosJsRoutingCompletion`  
**Date:** 2026-09-17  
**Feature Page:** [FOSJsRouting route completion and navigation](https://espend.de/phpstorm/plugin/symfony#fos-js-routing-completion)  

Completes route names in `Routing.generate()` and `fos.Router.generate()` in JavaScript and TypeScript, with navigation to the route definition and controller.

### Code Examples

```javascript
# Route names in JavaScript and TypeScript:
Routing.generate('app_product_show', {id: 42});
fos.Router.generate('app_product_show', {id: 42});
```

---

## PHP enum completion and navigation in YAML

**Feature ID:** `YamlPhpEnumCompletion`  
**Date:** 2026-10-27  
**Feature Page:** [PHP enum completion and navigation in YAML](https://espend.de/phpstorm/plugin/symfony#yaml-php-enum-completion)  

Completes `!php/enum`, enum class names and cases in YAML configuration. Navigate from an enum reference to its PHP declaration.

### Code Examples

```php
# PHP enum:
namespace App\Enum;

enum Status: string
{
    case ACTIVE = 'active';
    case DRAFT = 'draft';
}
```

```yaml
# Enum references in YAML:
parameters:
    app.default_status: !php/enum App\Enum\Status::ACTIVE
```

---

## Attribute-based Symfony forms

**Feature ID:** `AttributeFormTypeCompletion`  
**Date:** 2026-10-26  
**Feature Page:** [Attribute-based Symfony forms](https://espend.de/phpstorm/plugin/symfony#attribute-form-type-completion)  

Completes and navigates option keys in `#[AsFormType]` and `#[FormField]`, field names in PHP `get()`/`has()` calls, and form fields in Twig.

Supports inherited and trait properties, custom field names and nested forms. The class marked with `#[AsFormType]` is the form's data class.

### Code Examples

```php
# Form attributes and PHP field references:
use Symfony\Component\Form\Attribute\AsFormType;
use Symfony\Component\Form\Attribute\FormField;
use Symfony\Component\Form\Extension\Core\Type\TextType;

#[AsFormType]
class AddressData
{
    #[FormField(TextType::class)]
    public string $street;
}

#[AsFormType(options: ['label' => 'Contact'])]
class ContactData
{
    #[FormField(TextType::class, name: 'displayName', options: ['required' => true])]
    public string $name;

    #[FormField(AddressData::class)]
    public AddressData $address;
}

$form = $this->createForm(ContactData::class);
$form->get('displayName');
$form->has('displayName');
```

```twig
# Form field completion and navigation in Twig:
{{ form.displayName }}
{{ form.address.street }}
```

---

## Twig function hash completion from PHP types

**Feature ID:** `TwigFunctionHashCompletionProvider`  
**Date:** 2026-10-15  
**Feature Page:** [Twig function hash completion from PHP types](https://espend.de/phpstorm/plugin/symfony#twig-function-hash-completion-provider)  

Completes hash keys and literal string values from the PHPDoc array shape of a Twig function's PHP parameter, including nested shapes and imported Psalm or PHPStan type aliases.

Supports named arguments and nested arrays or lists. For `cva()` and `html_cva()`, completes default and compound variant names and values from the call's `variants` argument.

### Code Examples

```php
# PHP parameter type:
use Twig\Attribute\AsTwigFunction;

final class ButtonRuntime
{
    /**
     * @param array{size?: 'sm'|'lg', icon?: array{position?: 'start'|'end'}} $options
     */
    #[AsTwigFunction('button')]
    public function render(array $options): string
    {
        return '';
    }
}
```

```twig
# Matching keys and values in Twig:
{{ button({size: 'sm', icon: {position: 'start'}}) }}
```

```twig
# UX CSS variants in default and compound variants:
{% set button = cva(
    base: {display: 'flex'},
    variants: {
        size: {sm: {p: '2'}, lg: {p: '4'}}
    },
    defaultVariants: {size: 'sm'},
    compoundVariants: [{size: ['sm', 'lg'], css: {fontWeight: 'bold'}}]
) %}
```

```twig
# HTML CVA default and compound variants:
{% set button = html_cva(
    base: 'inline-flex',
    variants: {size: {sm: 'p-2', lg: 'p-4'}},
    defaultVariant: {size: 'sm'},
    compoundVariants: [{size: 'lg', class: 'font-bold'}]
) %}
```

---

## PHP attribute completion

**Feature ID:** `PhpAttributeCompletionContributor`  
**Date:** 2025-12-17  
**Feature Page:** [PHP attribute completion](https://espend.de/phpstorm/plugin/symfony#php-attribute-completion-contributor)  

Completes PHP attributes after `#` and adds imports, including `#[Lock]` for controller methods and `#[Encrypted]` for Doctrine entity properties.

### Code Examples

```
# Common suggestions:
#[Route]
#[Template]
#[IsGranted]
#[Cache]
#[Lock]
#[AsController]
#[AsCommand]
#[AsTwigComponent]
#[ExposeInTemplate]
#[AsTwigFunction]
#[AsTwigFilter]
#[Entity]
#[Column]
#[Encrypted]
```

---

## Vite and Reprise entry completion

**Feature ID:** `ViteGotoCompletionRegistrar`  
**Date:** 2026-09-09  
**Feature Page:** [Vite and Reprise entry completion](https://espend.de/phpstorm/plugin/symfony#vite-goto-completion-registrar)  

Entry completion and navigation in Vite and Reprise Twig functions.

### Code Examples

```twig
# Supported Twig functions:
{{ vite_entry_link_tags('app') }}
{{ vite_entry_script_tags('app') }}

{{ reprise_entry_script_tags('app') }}
{{ reprise_entry_link_tags(entryName: 'app') }}
{% set js = reprise_entry_js_files('app') %}
{% set css = reprise_entry_css_files('app') %}
{% if reprise_entry_exists('app') %}...{% endif %}
```

---

## Form type class constant completion

**Feature ID:** `FormCompletionContributor`  
**Date:** 2015-12-12  
**Feature Page:** [Form type class constant completion](https://espend.de/phpstorm/plugin/symfony#form-completion-contributor)  

Completes form type class constants in builder, factory and `createForm()` calls, including classes with `#[AsFormType]` and named `type` arguments.

### Code Examples

```php
# Attribute form types in supported calls:
use Symfony\Component\Form\Attribute\AsFormType;

#[AsFormType]
class ContactData {}

$builder->add('contact', ContactData::class);
$this->createForm(type: ContactData::class);
$factory->create(type: ContactData::class);
```

---

## Doctrine entity class constant completion

---

## Constraint message translation completion

**Feature ID:** `ConstraintMessageGotoCompletionRegistrar`  
**Date:** 2026-04-25  
**Feature Page:** [Constraint message translation completion](https://espend.de/phpstorm/plugin/symfony#constraint-message-goto-completion-registrar)  

Completes and navigates validation translation keys used in Symfony Constraint messages.

In addition to named `message:` arguments, the completion now supports array-style `'message'` keys in PHP constraint configuration.

### Code Examples

```php
# Attribute message argument:
#[Assert\NotBlank(message: 'product.name.not_blank')]
private string $name;
```

```php
# Array message key:
new Assert\NotBlank([
    'message' => 'product.name.not_blank',
]);
```

---

## Tag completion inside Attributes

---

## Service completion inside Autowire Attribute

---

## Parameter completion inside Autowire Attribute

---

## Service completion inside Autowire AsDecorator

---

## Doctrine QueryBuilder: Field completion

---

## Prioritized extends templates

---

## Incomplete Yaml named argument

---

## PHP service config argument completion

**Feature ID:** `PhpServiceConfigCompletion`  
**Date:** 2026-04-01  
**Feature Page:** [PHP service config argument completion](https://espend.de/phpstorm/plugin/symfony#php-service-config-completion)  

Completes service references for PHP array-style and fluent service definitions by looking at the configured service class constructor and setter signatures.

Navigation and completion also cover `ServicesConfigurator::alias()` targets in PHP service configuration files.

### Code Examples

```php
# Array-style service arguments:
use function Symfony\Component\DependencyInjection\Loader\Configurator\service;

return [
    App\Service\Mailer::class => [
        'arguments' => [
            service('mailer.transport'),
        ],
    ],
];
```

```php
# Fluent service config and alias target:
$services->set('app.mailer', App\Service\Mailer::class)
    ->args([service('mailer.transport')]);

$services->alias('App\Contracts\MailerInterface', 'app.mailer');
```

---

## !tagged_iterator tag name

---

## Prioritized include templates

---

## Prioritized embed templates

---

## Incomplete Completion for extends tags

---

## Incomplete Completion for include tags

---

## Incomplete Completion for embed tags

---

## HTML attribute completion with "function print block"

---

## Environment variable completion for env() expressions

**Feature ID:** `EnvironmentVariableContributor`  
**Date:** 2026-03-31  
**Feature Page:** [Environment variable completion for env() expressions](https://espend.de/phpstorm/plugin/symfony#environment-variable-contributor)  

Completes environment variable names inside Symfony `env()` expressions and navigates to the matching `.env` declaration.

The contributor reuses indexed dotenv variables so PHP, YAML, and XML service configuration can reference the same variables consistently.

### Code Examples

```php
# PHP service config:
return [
    'parameters' => [
        'dsn' => env('DATABASE_URL'),
    ],
];
```

```yaml
# YAML service config:
parameters:
  dsn: '%env(DATABASE_URL)%'
```

---

## Form translation key completion

**Feature ID:** `FormTranslationCompletion`  
**Date:** 2015-12-01  
**Feature Page:** [Form translation key completion](https://espend.de/phpstorm/plugin/symfony#form-translation-completion)  

Completes and navigates translation domains and keys in PHP form builders and in the options of `#[AsFormType]` and `#[FormField]`.

Supported form options include `translation_domain`, `choice_translation_domain`, `label`, `help`, `help_block`, `help_inline`, `placeholder`, and translated choice labels.

### Code Examples

```php
# Form option translations:
<?php
$builder->add('status', ChoiceType::class, [
    'translation_domain' => 'admin',
    'label' => 'product.status',
    'help' => 'product.status.help',
    'choices' => [
        'product.status.draft' => 'draft',
        'product.status.published' => 'published',
    ],
]);
```

```php
# Domain completion:
<?php
$builder->add('category', ChoiceType::class, [
    'choice_translation_domain' => 'admin',
]);
```

```php
# Translation options in form attributes:
use Symfony\Component\Form\Attribute\AsFormType;
use Symfony\Component\Form\Attribute\FormField;
use Symfony\Component\Form\Extension\Core\Type\TextType;

#[AsFormType(options: ['translation_domain' => 'admin'])]
class ProductData
{
    #[FormField(TextType::class, options: ['label' => 'product.title'])]
    public string $title;
}
```

---

## Include and embed context key completion

**Feature ID:** `TwigIncludeEmbedContextKeyCompletion`  
**Date:** 2026-05-10  
**Feature Page:** [Include and embed context key completion](https://espend.de/phpstorm/plugin/symfony#twig-include-embed-context-key-completion)  

Completes top-level variable names inside Twig `include` and `embed` context hashes from the target template.

The same context key can navigate back to the variable usage in the included template, so forwarded values stay connected to the template that expects them.

### Code Examples

```twig
# Included template variables:
{# product/_card.html.twig #}
{{ product.name }}
{{ currentView }}
```

```twig
# Context key completion:
{% include 'product/_card.html.twig' with {
    product: product,
    currentView: 'grid'
} only %}

{% embed 'product/_card.html.twig' with { product: product } %}
    {% block body %}{{ product.name }}{% endblock %}
{% endembed %}
```

---

## Controller render parameter key completion

**Feature ID:** `ControllerRenderParameterKeyCompletion`  
**Date:** 2019-08-21  
**Feature Page:** [Controller render parameter key completion](https://espend.de/phpstorm/plugin/symfony#controller-render-parameter-key-completion)  

Completes keys in controller render parameter arrays from the variables used by the rendered Twig template.

Completion is limited to root-level template variables and also works for templates whose visible variables come from include or embed context handling.

### Code Examples

```twig
# Rendered template variables:
{# product/show.html.twig #}
{{ product.name }}
{{ breadcrumbs.items|length }}

{% include 'product/_teaser.html.twig' with { teaser: teaser } %}
```

```php
# Controller parameter keys:
return $this->render('product/show.html.twig', [
    'product' => $product,
    'breadcrumbs' => $breadcrumbs,
    'teaser' => $teaser,
]);
```

```php
# Merged context arrays:
$context = ['product' => $product];

return $this->render('product/show.html.twig', array_merge(
    $context,
    ['breadcrumbs' => $breadcrumbs],
));
```

---

## Twig method-chain type resolution

**Feature ID:** `TwigMethodChainTypeResolution`  
**Date:** 2026-05-18  
**Feature Page:** [Twig method-chain type resolution](https://espend.de/phpstorm/plugin/symfony#twig-method-chain-type-resolution)  

Improves Twig completion, navigation, and inspections across chained method calls, property shortcuts, function/filter return types, and `enum()` cases.

This enables suggestions on expressions like `entry.children.entries`, method-call chains, and values returned by Twig functions or filters.

### Code Examples

```twig
# For-loop path resolution:
{# @var root \App\Dto\CategoryTree #}
{% for entry in root.children.entries %}
    {{ entry.name }}
{% endfor %}
```

```twig
# Function/filter return type chains:
{{ product_for_sku(sku).manufacturer.name }}
{{ order|latest_invoice.number }}
{{ enum('App\\Enum\\Status').ACTIVE.value }}
```

---

## Complete Twig constant() references

**Feature ID:** `TwigConstantEnumResolver`  
**Date:** 2026-05-28  
**Feature Page:** [Complete Twig constant() references](https://espend.de/phpstorm/plugin/symfony#twig-constant-enum-resolver)  

Completes and resolves PHP constants in Twig `constant()` calls, including fully qualified class constants, namespaced global constants, and object-relative constants.

The same resolver is used by navigation and Find Usages, so constant references in Twig stay connected to their PHP declarations.

### Code Examples

```twig
# Class and namespaced constants:
{{ constant('App\\Enum\\Status::ACTIVE') }}
{{ constant('BugDemo\\NAMESPACED_CONST') }}
```

```twig
# Object-relative constants:
{# @var suite \BugDemo\CardSuite #}
{{ constant('CLUBS', suite) }}
```

---

## Custom Twig operator completion

**Feature ID:** `TwigExpressionParserOperatorCompletion`  
**Date:** 2026-06-19  
**Feature Page:** [Custom Twig operator completion](https://espend.de/phpstorm/plugin/symfony#twig-expression-parser-operator-completion)  

Completes custom unary and binary operators from `getExpressionParsers()`, including aliases.

### Code Examples

```php
# Twig extension:
public function getExpressionParsers(): array
{
    return [
        new BinaryOperatorExpressionParser(BitwiseAndBinary::class, 'b-and', 18),
        new BinaryOperatorExpressionParser(ElvisBinary::class, '?:', 5, aliases: ['? :']),
        new UnaryOperatorExpressionParser(NotUnary::class, 'expression_not', 70),
    ];
}
```

```twig
# Twig expression:
{% if flags b-and mask %}
    ...
{% endif %}
```

---

