我在symfony2项目(2.6.*)中使用dompdf包(slik/dompdf包)从html生成pdf。这在我的dev(app_dev.php)和prod模式下的dev环境(MAMP)中运行良好。
在生产环境中,我遇到了一个错误,数据(DB)和代码(GIT)完全相同。所以我检查了服务器的配置(PHP版本)。有趣的是:当我用app_dev.php运行prod环境时,生成效果很好!!!app.php和app_dev.php之间的区别在哪里?
我得到的错误:德国中的错误消息
我的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;
}
我用变通办法解决了我的问题。我用mpdf包替换了dompdf包。这一个适用于我的解决方案:https://github.com/tasmanianfox/MpdfPortBundle