【发布时间】:2025-12-25 09:10:06
【问题描述】:
我正在尝试使用没有 barryvdh 包装器的 dompdf,因为我的项目中安装了 laravel 收银员并收到消息:
- Root composer.json requires barryvdh/laravel-dompdf ^0.9.0 -> satisfiable by barryvdh/laravel-dompdf[v0.9.0].
- Conclusion: don't install dompdf/dompdf v0.8.4 (conflict analysis result)
- Conclusion: don't install dompdf/dompdf v1.0.2 (conflict analysis result)
- Conclusion: don't install dompdf/dompdf v0.8.5 (conflict analysis result)
- Conclusion: don't install dompdf/dompdf v1.1.0 (conflict analysis result)
- Conclusion: don't install dompdf/dompdf v0.8.6 (conflict analysis result)
- Conclusion: don't install dompdf/dompdf v1.1.1 (conflict analysis result)
- laravel/cashier is locked to version v10.7.1 and an update of this package was not requested.
- laravel/cashier v10.7.1 requires dompdf/dompdf ^0.8.0 -> satisfiable by dompdf/dompdf[v0.8.0, ..., v0.8.6].
- You can only install one version of a package, so only one of these can be installed: dompdf/dompdf[v0.8.0, ..., v0.8.6, v1.0.0, ..., v1.1.1].
- barryvdh/laravel-dompdf v0.9.0 requires dompdf/dompdf ^1 -> satisfiable by dompdf/dompdf[v1.0.0, ..., v1.1.1].
- Conclusion: don't install dompdf/dompdf v1.0.1 (conflict analysis result)
每当我尝试安装软件包时。所以我使用收银员附带的 0.8.6 版本来生成我的 pdf。我做了一个简单的测试:
Route::get('manual-test-pdf', function () {
$dompdf = new Dompdf();
$html = view('pdf.test')->render();
$dompdf->loadHtml($html);
return $dompdf->stream();
});
尝试渲染视图:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Pdf test</title>
</head>
<body>
<h1>Test one</h1>
</body>
</html>
但结果始终是空白页。 ->render() 或 ->stream() 给出了相同的结果。我认为我做错了什么,但我没有在网上找到任何关于使用纯 dompdf 返回/渲染 pdf 的正确方法,因为每个人都使用 barryvdh 的版本。
谁能告诉我这个?
【问题讨论】:
-
似乎您有一个依赖项已经在使用它的较低版本,可能是
composer update
标签: php laravel dompdf laravel-cashier