Cannot resolve public path domPDF [ SOLVED ] I installed DOMpdf and includes it as well as config/app.php :
'providers' => [
....
Barryvdh\DomPDF\ServiceProvider::class,
],
'aliases' => [
....
'PDF' => Barryvdh\DomPDF\Facade::class,
]
It looks all right, but when I go to use it, I'm getting the following error (Cannot resolve public path), see :
$this->app->bind('dompdf', function ($app) {
$options = $app->make('dompdf.options');
$dompdf = new Dompdf($options);
$path = realpath(base_path('public'));
if ($path === false) {
throw new \RuntimeException('Cannot resolve public path');
}
$dompdf->setBasePath($path);
return $dompdf;
});
What could be happening?
do you have 'public' folder ?
@Snapey
I don't know which folder the error refers to. But my site is inside public_html, as you would expect
@Snapey
the error occurs when I call my view in the controller. But it's strange, I don't understand the reason for the error
$pdf = PDF::loadView('pdf')
@Snapey
I managed to solve. I just created the public folder and it solved... hehe
Thanks
@mvnobrega No I WOULD NOT EXPECT YOUR PROJECT TO BE IN PUBLIC_HTML
Thats just stupid and insecure
@Snapey Inside it has only the files from the public folder of laravel. All the rest of the files are outside of 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.
Package domPDF has own config file in Laravel project /config/dompdf.php
Set custom public_path param. Like:
'public_path' => base_path('public_html')
Hi everybody
i have an error when i want to display report in pdf format. the error is "Cannot resolve public path". Can anyone help me, where do you think the error is coming from?
Please sign in or create an account to participate in this conversation.