{"record":{"id":"90c63795b20b7976","repo":"twigphp/Twig","slug":"the-s-tag-is-part-of-the-s-which-is-not-installed-enabled","errorCode":null,"errorMessage":"The \"%s\" tag is part of the %s, which is not installed/enabled; try running \"composer require %s\".","messagePattern":"The \"(.+?)\" tag 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":39,"sourceCode":"            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]));\n        }\n\n        return false;\n    }\n}\n","sourceCodeStart":21,"sourceCodeEnd":45,"githubUrl":"https://github.com/twigphp/Twig/blob/a414c3a491defb5a60f2fc88ef79ff37c90010cd/extra/twig-extra-bundle/MissingExtensionSuggestor.php#L21-L45","documentation":"MissingExtensionSuggestor::suggestTag handles Twig tags. When a template uses a tag Twig cannot parse and that tag belongs to a known extension package (via Extensions::getTag), it throws a SyntaxError instructing the developer which package provides it. Like its siblings, it exists purely to produce better diagnostics.","triggerScenarios":"A template contains a tag (e.g. {% trans %}) listed in Extensions::getTag(), but the package registering that tag extension is not installed/enabled.","commonSituations":"Using {% trans %} or similar tags without symfony/twig-bridge; copying templates from a Symfony app into a plain Twig project; missing bundle registration after a framework upgrade.","solutions":["Run the composer command from the message, e.g. composer require symfony/twig-bridge.","Register the extension providing the tag on the Environment (or enable the bundle).","Rewrite the template to avoid the tag (e.g. use the trans filter instead of the tag).","Verify the tag spelling matches the extension's documented syntax."],"exampleFix":"// before\n{% trans %}Hello{% endtrans %}\n// after\n$ composer require symfony/twig-bridge\n$twig->addExtension(new \\Symfony\\Bridge\\Twig\\Extension\\TranslationExtension());","handlingStrategy":"try-catch","validationCode":"<?php\nuse Twig\\Extra\\TwigExtraBundle\\Extensions;\nif (Extensions::getFunction('currency_symbol') && !class_exists(\\Twig\\Extra\\Intl\\IntlExtension::class)) {\n    // require twig/intl-extra before rendering\n}","typeGuard":"<?php\nfunction functionAvailable(Twig\\Environment $twig, string $name): bool\n{\n    return $twig->getFunction($name) !== false;\n}","tryCatchPattern":"<?php\nuse Twig\\Error\\SyntaxError;\ntry {\n    $html = $twig->render('template.twig');\n} catch (SyntaxError $e) {\n    if (str_contains($e->getMessage(), 'composer require')) {\n        error_log($e->getMessage()); // install hinted package\n    }\n    throw $e;\n}","preventionTips":["List all Twig functions your templates use and ensure their provider packages are in composer.json.","Call $twig->getFunction($name) in a health check at startup to fail fast.","Keep bundle/extension registration centralized so nothing is silently skipped.","Run template-rendering smoke tests in CI before deploys."],"tags":["php","twig","tag","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"}