{"record":{"id":"81203750927c3c75","repo":"twigphp/Twig","slug":"the-s-filter-is-part-of-the-s-which-is-not-installed-enabled","errorCode":null,"errorMessage":"The \"%s\" filter is part of the %s, which is not installed/enabled; try running \"composer require %s\".","messagePattern":"The \"(.+?)\" filter is part of the (.+?), which is not installed/enabled; try running \"composer require (.+?)\"\\.","errorType":"exception","errorClass":"Twig\\Error\\SyntaxError","httpStatus":null,"severity":"error","filePath":"extra/twig-extra-bundle/MissingExtensionSuggestor.php","lineNumber":21,"sourceCode":"/*\n * This file is part of Twig.\n *\n * (c) Fabien Potencier\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nnamespace Twig\\Extra\\TwigExtraBundle;\n\nuse Twig\\Error\\SyntaxError;\n\nfinal class MissingExtensionSuggestor\n{\n    public function suggestFilter(string $name): bool\n    {\n        if ($filter = Extensions::getFilter($name)) {\n            throw new SyntaxError(\\sprintf('The \"%s\" filter is part of the %s, which is not installed/enabled; try running \"composer require %s\".', $name, $filter[0], $filter[1]));\n        }\n\n        return false;\n    }\n\n    public function suggestFunction(string $name): bool\n    {\n        if ($function = Extensions::getFunction($name)) {\n            throw new SyntaxError(\\sprintf('The \"%s\" function is part of the %s, which is not installed/enabled; try running \"composer require %s\".', $name, $function[0], $function[1]));\n        }\n\n        return false;\n    }\n\n    public function suggestTag(string $name): bool\n    {\n        if ($function = Extensions::getTag($name)) {\n            throw new SyntaxError(\\sprintf('The \"%s\" tag is part of the %s, which is not installed/enabled; try running \"composer require %s\".', $name, $function[0], $function[1]));","sourceCodeStart":3,"sourceCodeEnd":39,"githubUrl":"https://github.com/twigphp/Twig/blob/a414c3a491defb5a60f2fc88ef79ff37c90010cd/extra/twig-extra-bundle/MissingExtensionSuggestor.php#L3-L39","documentation":"MissingExtensionSuggestor::suggestFilter is a Twig runtime-time helper that improves error messages. When a template uses a filter Twig cannot resolve, this method checks the known Extensions map; if the filter belongs to an uninstalled twig extension package it throws a SyntaxError telling the developer exactly which composer package to require.","triggerScenarios":"A template calls a filter (e.g. trans, inline) registered in Extensions::getFilter(), but the twig extension package providing it is not installed or not registered on the Environment.","commonSituations":"Using twig trans filters without installing symfony/twig-bridge or twig/intl-extra; moving from full framework to standalone Twig and losing auto-registered extra extensions; typo'd filter names that coincidentally match known extension filters.","solutions":["Run the composer command named in the message, e.g. composer require twig/intl-extra.","Register the installed extension on the Environment: $twig->addExtension(new IntlExtension());","Check the filter name for typos against the intended extension's docs.","If the filter is genuinely custom, verify your own extension is added to the Twig Environment."],"exampleFix":"// before\n{{ user.name|trans }}\n// after\n$ composer require symfony/twig-bridge\n$twig->addExtension(new \\Symfony\\Bridge\\Twig\\Extension\\TranslationExtension());","handlingStrategy":"fallback","validationCode":"<?php\nif (class_exists(\\Symfony\\Component\\String\\Inflector\\SpanishInflector::class)) {\n    $plural = $stringExt->plural($word, 'es');\n} else {\n    $plural = $word; // or install symfony/string\n}","typeGuard":"<?php\nfunction spanishInflectionAvailable(): bool\n{\n    return class_exists(\\Symfony\\Component\\String\\Inflector\\SpanishInflector::class);\n}","tryCatchPattern":"<?php\nuse Twig\\Error\\RuntimeError;\ntry {\n    $plural = $stringExt->plural($word, 'es');\n} catch (RuntimeError $e) {\n    if (str_contains($e->getMessage(), 'SpanishInflector is not available')) {\n        $plural = $word; // fallback\n    } else {\n        throw $e;\n    }\n}","preventionTips":["Pin symfony/string in composer.json and commit composer.lock so every deploy has SpanishInflector.","Run composer install (not manual vendor copies) in CI and production.","Check class_exists for locale-specific inflectors at boot and fail fast with a clear message.","Only pass 'es' as locale when the Spanish inflector dependency is guaranteed."],"tags":["php","twig","filter","missing-extension"],"backgroundTag":"missing-optional-dependency","analyzedSha":"a414c3a491defb5a60f2fc88ef79ff37c90010cd","analyzedAt":"2026-09-13T15:10:46.849Z","contentChangedAt":"2026-09-13T15:10:46.849Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}