mpdf更改温度路径(composer程序包) [英] mpdf change temp path (composer package)

查看:213
本文介绍了mpdf更改温度路径(composer程序包)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经通过作曲家安装了mpdf/mpdf.

I have installed mpdf/mpdf via composer.

所有功能都可以在开发环境中完美运行,但是在生产/暂存中,出现权限错误.

All works perfectly in development environment, however in production / staging, I get a permissions error.

file_put_contents(\/.../ttfontdata\/dejavusanscondensed.GSUBGPOStables.dat): failed to open stream: Permission denied' in .../shared\/vendor\/mpdf\/mpdf\/classes\/ttfontsuni.php:999\nStack trace:\n#0 [internal function]: Illuminate\\Exception\\Handler->handleError(2, 'file_put_conten...', '...', 999, Array)\n#1 

根据mpdf文档,我需要定义存储文件夹的路径:

As per mpdf documentation, I need to define the path for my storage folder:

// Tried this at top of index.php before require bootstrap/autoload.php
define("_MPDF_TEMP_PATH", dirname(__FILE__) . '/../app/storage/mpdf/');

// Tried this just before creating a new mpdf
define("_MPDF_TEMP_PATH", storage_path() . '/mpdf/');

我正在使用Laravel作为框架-mpdf不会使用我指定的临时文件夹

I am using Laravel as a framework - and mpdf just will not use my specified temp folder

推荐答案

我知道这是一个老问题,但是我遇到了同样的问题.就像您最初建议的那样,您可以在加载mPDF库之前定义临时路径,但是还需要定义字体数据路径.

I know this is an old question, but I had the same issue. Just like you originally suggested, you can define the temp path prior to loading the mPDF library, but the font data path also needs to be defined.

我将此添加到了/bootstrap/autoload.php文件的顶部:

I added this to the top of my /bootstrap/autoload.php file:

define("_MPDF_TEMP_PATH", __DIR__.'/../storage/framework/pdf/');
define("_MPDF_TTFONTDATAPATH", __DIR__.'/../storage/framework/pdf/fonts/');

此外,我还必须手动创建/pdf/pdf/fonts目录.

Additionally, I had to create the /pdf and /pdf/fonts directories manually.

可能有一种更干净的方法可以做到这一点,但这是一个快速的解决方法.

There is probably a cleaner way to do this, but this is a quick fix.

这篇关于mpdf更改温度路径(composer程序包)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆