5

I am trying to send emails with Symfony. Everything works perfect locally. But on server I get following errore in prod.log:

assetic.ERROR: The template "SecurityBundle:Collector:security.html.twig" contains an error: Unknown "profiler_dump" function in "SecurityBundle:Collector:security.html.twig" at line 180.

assetic.ERROR: The template "DoctrineBundle:Collector:db.html.twig" contains an error: Unknown "profiler_dump" function in "DoctrineBundle:Collector:db.html.twig" at line 241

These are bundles I have in composer.json

    "php": ">=5.5.9",
    "symfony/symfony": "3.1.*",
    "doctrine/orm": "^2.5",
    "doctrine/doctrine-bundle": "^1.6",
    "doctrine/doctrine-cache-bundle": "^1.2",
    "symfony/swiftmailer-bundle": "^2.3",
    "symfony/monolog-bundle": "3.0.1",
    "symfony/polyfill-apcu": "^1.0",
    "sensio/distribution-bundle": "^5.0",
    "sensio/framework-extra-bundle": "^3.0.2",
    "incenteev/composer-parameter-handler": "^2.0",
    "friendsofsymfony/user-bundle": "~2.0@dev",
    "justinrainbow/json-schema": "~2.0",
    "jms/serializer-bundle": "1.1.0",
    "lexik/jwt-authentication-bundle": "1.6.0",
    "symfony/assetic-bundle": "^2.8",
    "stof/doctrine-extensions-bundle": "^1.2",
    "guzzlehttp/guzzle": "~6.0",
    "knplabs/knp-paginator-bundle": "^2.5",
    "mapado/mysql-doctrine-functions": "1.*",
    "hampe/zurb-ink-bundle": "^2.2",

This are bundles in AppKernel class

  $bundles = [
        new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
        new Symfony\Bundle\SecurityBundle\SecurityBundle(),
        new Symfony\Bundle\TwigBundle\TwigBundle(),
        new Symfony\Bundle\MonologBundle\MonologBundle(),
        new Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(),
        new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
        new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
        new FOS\UserBundle\FOSUserBundle(),
        new AdminBundle\AdminBundle(),
        new APIBundle\APIBundle(),
        new JMS\SerializerBundle\JMSSerializerBundle(),
        new Lexik\Bundle\JWTAuthenticationBundle\LexikJWTAuthenticationBundle(),
        new Symfony\Bundle\AsseticBundle\AsseticBundle(),
        new Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle(),
        new NotificationBundle\NotificationBundle(),
        new Hampe\Bundle\ZurbInkBundle\HampeZurbInkBundle(),
    ];
2
  • can you share your AppKernel class?
    – Matteo
    Commented Mar 20, 2017 at 9:11
  • @Matteo ok, added
    – blahblah
    Commented Mar 20, 2017 at 9:17

3 Answers 3

8

By default, AsseticBundle will try to handle the templates of all enabled bundles which leads to errors when enabled bundles ship with templates that rely on features not being loaded in the prod environment. You can solve your issue by explicitly listing all bundles that should be handled by Assetic using the assetic.bundles option.

4
  • Is this is possibly a bug in Doctrine?
    – Henry
    Commented Sep 14, 2017 at 0:26
  • No, DoctrineBundle does not use this template in the prod environment (to be clear it's the profiler that is not used here and thus not rendering this template).
    – xabbuh
    Commented Sep 14, 2017 at 10:11
  • The problem is the template exists in a bundle that is included in prod. So assetic will try to process it regardless of whether it's used.
    – Henry
    Commented Sep 14, 2017 at 23:02
  • The only working link is this: symfony.com/doc/3.3/reference/configuration/assetic.html you can also try php bin/console debug:config assetic to see current settings
    – StockBreak
    Commented Sep 26, 2018 at 9:39
1

profiler_dump method comes from Symfony's WebProfilerBundle. This bundle is not applied to Kernel in production mode, and it should not be (WebProfiler toolbar should be enabled only during development). You should remove those calls from twig template.

1
  • This template is part of the doctrine bundle so can't be removed so easily.
    – Henry
    Commented Sep 14, 2017 at 0:22
0

I've solved this by creating twig extension defining empty function profiler_dump and loading this twig extension only in production.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.