assetic.ERROR "DoctrineBundle:Collector:db.html.twig" contains an error: Unknown "profiler_dump" function
assetic.ERROR "DoctrineBundle:Collector:db.html.twig" contains an error: Unknown "profiler_dump" function
我正在尝试使用 Symfony 发送电子邮件。一切都在本地完美运行。但是在服务器上我在 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
这些是我在 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",
这是 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(),
];
profiler_dump
方法来自 Symfony 的 WebProfilerBundle。
此捆绑包未应用于生产模式下的内核,也不应应用于(WebProfiler 工具栏应仅在开发期间启用)。您应该从 Twig 模板中删除这些调用。
默认情况下,AsseticBundle 将尝试处理所有启用的捆绑包的模板,这会在启用的捆绑包附带依赖于未在 prod
环境中加载的功能的模板时导致错误。您可以通过使用 assetic.bundles
option.
明确列出应由 Assetic 处理的所有捆绑包来解决您的问题。
我通过创建定义空函数的 twig 扩展 profiler_dump
并仅在生产中加载此 twig 扩展来解决此问题。
我正在尝试使用 Symfony 发送电子邮件。一切都在本地完美运行。但是在服务器上我在 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
这些是我在 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",
这是 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(),
];
profiler_dump
方法来自 Symfony 的 WebProfilerBundle。
此捆绑包未应用于生产模式下的内核,也不应应用于(WebProfiler 工具栏应仅在开发期间启用)。您应该从 Twig 模板中删除这些调用。
默认情况下,AsseticBundle 将尝试处理所有启用的捆绑包的模板,这会在启用的捆绑包附带依赖于未在 prod
环境中加载的功能的模板时导致错误。您可以通过使用 assetic.bundles
option.
我通过创建定义空函数的 twig 扩展 profiler_dump
并仅在生产中加载此 twig 扩展来解决此问题。