I know there's already a lot discussion about this since I already tried to find a way to resolved this, but still failed.
this is the code to generate dompdf on the controller
// instantiate and use the dompdf class
$dompdf = new Dompdf();
$dompdf->loadHtml(view('detail-pdf', compact('listing', 'route', 'images')));
// Set the option
$options = $dompdf->getOptions();
$options->setIsRemoteEnabled(true);
$options->setIsPhpEnabled(true);
$context = stream_context_create([
'ssl' => [
'verify_peer' => FALSE,
'verify_peer_name' => FALSE,
'allow_self_signed'=> TRUE
]
]);
$options->setHttpContext($context);
$dompdf->setOptions($options);
// (Optional) Setup the paper size and orientation
$dompdf->setPaper('A4', 'potrait');
// Render the HTML as PDF
$dompdf->render();
// Output the generated PDF to Browser
$dompdf->stream($listing->code);
I already test with direct route like "var/www/html/project/public/storage/request/temp/image.jpg" and direct link like "http://127.0.0.1:8000/storage/request/temp/image.jpg" and generated link like asset('storage/request/temp/image.jpg')
but it still displayed as "Image not found or type unknown". But I already test it with random image on Unsplash just to test if it works with online link and it's works, so my conclusion that it's only failed with images from local server.
Oh and I tried to change some setting on php.ini allow_url_fopen = on
but since I use the laravel php server to run the site locally I don't know if this is the actual php.ini file for the server that's running (project/vendor/laravel/sailtime/runtimes/8.0/php.ini), I actually edit all the php.ini file that appears on runtimes folder since there's a few option like 8.0, 8.1, 8.2
I use dompdf 2.0.0 but since there's already a newer version I tried to update it to 2.0.3 in hope that the newer version has the problem fixed but it still failed
FYI I already test the output for the images link before and after it passed onto the blade file and it has shown the output correctly so I don't think the problem is from the link but rather something with permission that won't allowed the image to be accessed.