Search code examples
symfonytwigsymfony4twig-filter

Twig Error Unknown "format_number" filter on Symfony 4 project


format_number was introduced in 2.12, as far as I can tell I have 2.13, using {{ constant('Twig_Environment::VERSION') }} outputs The current version is 2.13.0

Here is my composer json, I just dont see a reason I should be getting an unknown filter in this symfony 4.4.* project.

"require": {
        "php": "^7.1.3",
        "ext-ctype": "*",
        "ext-iconv": "*",
        "ext-json": "*",
        "beberlei/doctrineextensions": "^1.2",
        "friendsofsymfony/jsrouting-bundle": "^2.3",
        "sensio/framework-extra-bundle": "^5.4",
        "symfony/asset": "4.4.*",
        "symfony/console": "4.4.*",
        "symfony/dotenv": "4.4.*",
        "symfony/flex": "^1.3.1",
        "symfony/form": "4.4.*",
        "symfony/framework-bundle": "4.4.*",
        "symfony/orm-pack": "^1.0",
        "symfony/security-bundle": "4.4.*",
        "symfony/swiftmailer-bundle": "^3.2",
        "symfony/twig-bridge": "4.*",
        "symfony/twig-bundle": "4.4.*",
        "symfony/validator": "4.4.*",
        "symfony/web-server-bundle": "4.4.*",
        "symfony/yaml": "4.4.*",
        "twig/twig": "2.*"
    },

Solution

  • format_number filter is not part of the main twig/twig package. You need the Twig Extra package/bundle which you can install with:

    composer require twig/extra-bundle twig/intl-extra