【问题标题】:Fatal error: Class 'Imagine\Gd\Imagine' - Symfony 2 Framework致命错误:类 'Imagine\Gd\Imagine' - Symfony 2 框架
【发布时间】:2015-11-20 14:13:45
【问题描述】:

我尝试在 symfony 2 中实现 liipbundle。但是当我将这个imagine_filter('thumbnail') 添加到图像中时,它返回一个错误:

致命错误:类 'Imagine\Gd\Imagine' 未在 /home/piripz8g/public_html/app/cache/prod/appProdProjectContainer.php 第588行

这是我在配置文件中的代码:

liip_imagine:
    resolvers:
       default:
          web_path: ~

    filter_sets:
        cache: ~
        thumbnail:
            quality: 75
            filters:
                thumbnail: { size: [120, 90], mode: outbound }

路由:

_liip_imagine:
    resource: "@LiipImagineBundle/Resources/config/routing.xml"

应用内核:

    new Liip\ImagineBundle\LiipImagineBundle(),

树枝:

{{ asset(f.path|imagine_filter('thumbnail')) }}

【问题讨论】:

  • 清除缓存:php app/console cache:clear -e prod
  • 我试过这个命令,但没有成功
  • 尝试在开发模式下运行。为什么您甚至会在生产模式下收到错误消息,这有点令人困惑,因为您通常只会看到白屏。除非你打开了调试。无论如何,开发模式应该让您更好地了解失败的原因。

标签: symfony composer-php liipimaginebundle


【解决方案1】:

我想你忘了把 bundle 添加到 app/AppKernel.php

// ...
class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            // ...

            new Liip\ImagineBundle\LiipImagineBundle(),
        );

        // ...
    }

    // ...
}

【讨论】:

  • 问题的 appKernel 部分强烈暗示他做到了。
  • 这不是这部分在哪里的信息(可能只在开发或测试环境中编写)
【解决方案2】:

似乎没有加载php5-gd。您可以输入以下命令来验证是否加载了 php5-gd:

$ php5 -m | grep -i gd

如果没有加载...

$ sudo apt-get install php5-gd
$ sudo service apache2 restart

【讨论】:

    猜你喜欢
    • 2013-01-04
    • 1970-01-01
    • 1970-01-01
    • 2014-04-19
    • 2019-07-18
    • 2013-07-12
    • 1970-01-01
    • 2016-12-10
    • 1970-01-01
    相关资源
    最近更新 更多