简体   繁体   English

我如何在没有包装器的情况下将 dompdf 与 laravel 一起使用

[英]How i use dompdf with laravel without a wrapper

I'm trying to use dompdf without the barryvdh's wrapper because I have laravel cashier installed on my project and get the message:我正在尝试使用没有 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)

Whenever I tried to install the package.每当我尝试安装 package 时。 So I'm using the 0.8.6 version that ships with the cashier to generate my pdf.所以我使用收银员附带的 0.8.6 版本来生成我的 pdf。 I made a simple test:我做了一个简单的测试:

Route::get('manual-test-pdf', function () {
  $dompdf = new Dompdf();
  $html = view('pdf.test')->render();
  $dompdf->loadHtml($html);

  return $dompdf->stream();
});

Trying to render the view:尝试渲染视图:

<!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>

But the result is always a blank page.但结果始终是空白页。 ->render() or ->stream() gave the same result. ->render()->stream()给出了相同的结果。 I think I'm doing something wrong, but I didn't found anything online about the correct way of returning/rendering a pdf with pure dompdf since everyone uses barryvdh's version.我想我做错了什么,但我没有在网上找到任何关于使用纯 dompdf 返回/渲染 pdf 的正确方法,因为每个人都使用 barryvdh 的版本。

Can anyone give me a light on this one?谁能告诉我这个?

The latest stable version of laravel/cashier as of this posting is v13.7.0 which requires:截至本文发布时,laravel/cashier 的最新稳定版本是v13.7.0 ,它需要:
"dompdf/dompdf": "^0.8.6|^1.0.1" . "dompdf/dompdf": "^0.8.6|^1.0.1"
"php": "^7.3|^8.0"

The latest stable version of barryvdh/laravel-dompdf as of this posting is v0.9.0 which requires: "dompdf/dompdf": "^1" barryvdh/laravel-dompdf 的最新稳定版本是v0.9.0 ,它需要: "dompdf/dompdf": "^1"
"php": "^7.1 || ^8.0"

It looks a lot like these packages are compatible with each other for recent PHP versions.对于最近的 PHP 版本,这些软件包看起来很像彼此兼容。

Your composer.json file already specifies:您的 composer.json 文件已经指定:
"barryvdh/laravel-dompdf": "^0.9.0"
But your composer.json file is locking laravel/cashier to version v10.7.1.但是您的 composer.json 文件将 laravel/cashier 锁定到 v10.7.1 版本。 So basically you just need to update your cachier version from v10.7.1 to a more recent build such as the current latest as of the time of this posting: v13.7.0所以基本上你只需要将你的 cachier 版本从 v10.7.1 更新到更新的版本,例如截至本文发布时的最新版本:v13.7.0

You should be able to get by with a simple:你应该能够通过一个简单的:
composer update . composer update

You can also trying deleting your composer.lock file so you're not locked down to a specific version then retry installing/updating with either composer install or composer update .您还可以尝试删除您的 composer.lock 文件,这样您就不会被锁定到特定版本,然后使用composer installcomposer update重试安装/更新。
If you need to retain any specific versions of something after deleting the composer.lock file, such as if it breaks code, specify them in your composer.json file.如果您在删除 composer.lock 文件后需要保留任何特定版本的内容,例如如果它破坏了代码,请在您的 composer.json 文件中指定它们。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM