【问题标题】:dompdf in symfony only works in dev envirenmentsymfony 中的 dompdf 仅适用于开发环境
【发布时间】:2016-01-12 07:56:42
【问题描述】:

我在我的 symfony2-project (2.6.*) 中使用 dompdf-bundle (slik/dompdf-bundle) 从 html 生成 pdf。这在我的开发环境(MAMP)中的开发(app_dev.php)和产品模式中运行良好。

在 prod 环境中,我得到一个完全相同的数据 (DB) 和代码 (GIT) 的错误。所以我检查了服务器的配置(PHP版本)。有趣:当我使用 app_dev.php 运行 prod-envirenment 时,生成工作正常!!! app.php 和 app_dev.php 的区别在哪里?

我得到的错误: Error message in german

我的 AppKernel.php:

public function registerBundles()
    {
        $bundles = array(
            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 Symfony\Bundle\AsseticBundle\AsseticBundle(),
            new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
            new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
            new AppBundle\AppBundle(),
            new GaertnerhuusBundle\GaertnerhuusBundle(),
            new GaertnerhuusAdminBundle\GaertnerhuusAdminBundle(),
            new Slik\DompdfBundle\SlikDompdfBundle()
        );

        if (in_array($this->getEnvironment(), array('dev', 'test'))) {
            $bundles[] = new Symfony\Bundle\DebugBundle\DebugBundle();
            $bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
            $bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle();
            $bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle();
        }

        return $bundles;
    }

【问题讨论】:

  • 您是否为开发环境添加了捆绑包?请告诉我们你加载包的位置:AppKernel.php
  • @ibasaw 查看更新后的描述,感谢您的支持。
  • 你得到什么错误?

标签: php symfony dompdf


【解决方案1】:

我通过变通方法解决了我的问题。我用 mpdf 包替换了 dompdf 包。这个适用于我的解决方案: https://github.com/tasmanianfox/MpdfPortBundle

【讨论】:

    猜你喜欢
    • 2021-08-08
    • 2023-03-13
    • 1970-01-01
    • 1970-01-01
    • 2013-11-13
    • 1970-01-01
    • 1970-01-01
    • 2021-02-17
    • 2020-03-21
    相关资源
    最近更新 更多