尝试在 Laravel 中读取 barryvh/dompdf 时无法解析公共路径

发布于 2025-01-10 12:06:27 字数 721 浏览 0 评论 0原文

我将 Laravel 应用程序部署到共享托管。然后,我将文件夹分为两个 DOMAIN(包含所有其他文件夹)和 public_html(包含公共目录中的文件)。然后我像这样公开修改了index.php文件

  require __DIR__.'/../domain/vendor/autoload.php';

/*
|--------------------------------------------------------------------------
| Run The Application
|--------------------------------------------------------------------------
|
| Once we have the application, we can handle the incoming request using
| the application's HTTP kernel. Then, we will send the response back
| to this client's browser, allowing them to enjoy our application.
|
*/

$app = require_once __DIR__.'/../domain/bootstrap/app.php';

该应用程序似乎运行良好,除了一些功能(例如barrydompdf)给我带来了错误 无法解析公共路径 请知道我该如何解决这个问题。预先感谢大家。

I deployed a laravel app to shared hosting. Then I separated the folders into two DOMAIN containing the all the other folders and public_html containing the files in the public directory. I then modified index.php file in public like this

  require __DIR__.'/../domain/vendor/autoload.php';

/*
|--------------------------------------------------------------------------
| Run The Application
|--------------------------------------------------------------------------
|
| Once we have the application, we can handle the incoming request using
| the application's HTTP kernel. Then, we will send the response back
| to this client's browser, allowing them to enjoy our application.
|
*/

$app = require_once __DIR__.'/../domain/bootstrap/app.php';

The app seems to work well, except for some features like the barrydompdf that gives me the error
Cannot resolve public path
Please any idea on how I can fix this. Thank you all in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

时光礼记 2025-01-17 12:06:27

这是 DOMPDF 最愚蠢的错误。
要解决这个错误,你需要做的就是在项目目录中创建一个public文件夹,虽然它没有什么用。

This is the most stupid error by DOMPDF.
To resolve this error, all you need to do is to create a public folder in project directory, Although it is of no use.

你好,陌生人 2025-01-17 12:06:27

remplace

'public_path' => null

'public_path' => base_path()

文件路径

/config/dompdf.php

您可以在这里看到相同的主题

https://laracasts.com/discuss/频道/一般讨论/cannot-resolve-public-path-dompdf

remplace

'public_path' => null

for

'public_path' => base_path()

to file path

/config/dompdf.php

you can see the same topic here

https://laracasts.com/discuss/channels/general-discussion/cannot-resolve-public-path-dompdf

橙幽之幻 2025-01-17 12:06:27

这个问题已经提交到 DOMPDF Git 并且人们已经找到了它的解决方法。

走这条路

供应商/barryvdh/laravel-dompdf/src

编辑

ServiceProvider.php

搜索

base_path('公共')

并将其替换为

公共路径()

或者您可以在您的代码库目录中创建一个公共文件夹

编辑:
当您的代码库没有公用文件夹并且您已将公用文件夹分离到 public_html 时,就会发生这种情况。

This issue is submitted to DOMPDF Git already and people have found workaround of it.

Go to this path

vendor/barryvdh/laravel-dompdf/src

Edit

ServiceProvider.php

Search for

base_path('public')

and replace it with

public_path()

OR YOU CAN JUST CREATE A PUBLIC FOLDER IN YOUR CODEBASE DIRECTORY

EDIT:
This happens when your code base has no public folder and you have separated your public folder to public_html.

写给空气的情书 2025-01-17 12:06:27

切勿编辑供应商文件夹下的内容

只需在 config/app.php 中添加此属性

'public_path' => public_path(),

Never edit the content under the vendor folder

Just add this property in your config/app.php

'public_path' => public_path(),
三寸金莲 2025-01-17 12:06:27

解决方案只是在项目的根目录中创建 public 文件夹,因为当您尝试从供应商文件夹更改 dompdf 包的公共路径时,如果您更新 Composer,它会自动将 public_html 目录更改为 publi

The solution is simply to create public folder in root of your project because when you try to change the public path of dompdf package from the vendor folder and after that if you update the composer it will automatically change the public_html directory to publi

情定在深秋 2025-01-17 12:06:27

我在解决这个问题时遇到了同样的问题。我删除了文件夹供应商:

rm -rf vendor

然后我再次安装库:

composer install

现在它工作正常。

I had the same problem with resolving this. I removed the folder vendor:

rm -rf vendor

and then I install the libraries again with:

composer install

With this now it is working fine.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文