php - 将 PHP 从版本 5 更新到 7.3.1 后 Laravel mpdf 不起作用
问题描述
将服务器上的 PHP 更新到版本 7.3.1 和将 mpdf 更新到版本 8 后,不会生成 pdf。mpdf 的文件夹属性 -> 755
代码:
use Mpdf\Mpdf;
require_once __DIR__ . '/vendor/autoload.php';
$pdf = new \Mpdf\Mpdf(['tempDir' => $_SERVER["DOCUMENT_ROOT"].'/assets/temp']);
$pdf->SetDisplayMode('fullpage');
$pdf->SetProtection(array('print'));
$stylesheet = file_get_contents($_SERVER['DOCUMENT_ROOT'].'/assets/css/invoice.css');
$pdf->WriteHTML($stylesheet,1);
$pdf->WriteHTML($html_invoice,2);
$pdf_path = $_SERVER['DOCUMENT_ROOT'].'/assets/invoices/'.$invoice_id.'_'.$this->getPaymentSessionId().'.pdf';
$pdf->Output($pdf_path,"F");
从版本 7 起还有什么需要改变的吗?
作曲家.json:
"require": {
"php": ">=7.1.3",
"alaouy/youtube": "^2.2",
"anhskohbo/no-captcha": "3.*",
"anlutro/l4-settings": "^0.4.6",
"aws/aws-sdk-php-laravel": "~3.0",
"components/jquery": "^3.3",
"components/jqueryui": "^1.12",
"danielstjules/stringy": "^3.1",
"fideloper/proxy": "~4.0",
"hashids/hashids": "^3.0",
"hazestudio/laravel-gopay-sdk": "^0.1.5",
"illuminate/support": "5.7.0",
"intervention/image": "^2.3",
"jenssegers/agent": "^2.5",
"kylekatarnls/laravel-carbon-2": "^1.0.0",
"laracasts/presenter": "^0.2.1",
"laravel/framework": "^5.7.0",
"laravel/socialite": "^3.0",
"laravelcollective/html": "^5.1",
"league/fractal": "^0.16.0",
"mpdf/mpdf": "^8.0",
"nesbot/carbon": "2.0.0-beta2 as 1.26.3",
"paragonie/random_compat": "~1.4",
"predis/predis": "^1.1",
"proengsoft/laravel-jsvalidation": "2.3.*",
"tymon/jwt-auth": "1.0.0-rc.3",
"webpatser/laravel-countries": "dev-master"
尝试降级到 7.1.7 mpdf 版本:
composer require mpdf/mpdf 7.1.7
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Installation request for mpdf/mpdf 7.1.7 -> satisfiable by mpdf/mpdf[v7.1.7].
- Conclusion: remove setasign/fpdi v2.2.0
- Conclusion: don't install setasign/fpdi v2.2.0
- mpdf/mpdf v7.1.7 requires setasign/fpdi 1.6.* -> satisfiable by setasign/fpdi[1.6.0, 1.6.1, 1.6.2].
- Can only install one of: setasign/fpdi[1.6.0, v2.2.0].
- Can only install one of: setasign/fpdi[1.6.1, v2.2.0].
- Can only install one of: setasign/fpdi[1.6.2, v2.2.0].
- Installation request for setasign/fpdi (locked at v2.2.0) -> satisfiable by setasign/fpdi[v2.2.0].
Installation failed, reverting ./composer.json to its original content.
错误:
Fatal error: Uncaught Error: Class 'Mpdf\Mpdf' not found in C:\xampp\htdocs\test\public\info.php:6 Stack trace: #0 {main} thrown in C:\xampp\htdocs\test\public\info.php on line 6
解决方案
推荐阅读
- angular - 角度7显示来自对象数组的图像
- html - 在列表中捕获不同 ng-switch 的值
- android - Kotlin spinner 使用 2 路数据绑定在 Textview 中设置选定值
- sql - 根据每个字段的顺序查询返回列表(SQL)
- ssh - 如何通过 SSH 在 Windows Monitor 上打开 selenium 浏览器?
- c++ - OpenGL中的同步
- javascript - ASP.NET Core API 中的模型绑定始终为空
- javascript - 使用带有样式组件的自定义组件时无法触发函数 onClick
- python - Numpy 数组理解
- java - 在java中获取谷歌存储桶的大小