I recently build a small project for a company, and decided to use Laravels Cashier package. Everything runs smoothly, but I ran into an error today, when trying to output/download the paying users invoice.
FatalErrorException in Invoice.php line 248:
Class 'DOMPDF' not found
I then decided to make a quick Google search, but no one seems to have some kind of solution to this.
Im using the Latest version of Laravel, just recently updated the whole server, and the same goes with Cashier and Dompdf (freshly installed).
Invoice.php line 248:
public function pdf(array $data)
{
if (! defined('DOMPDF_ENABLE_AUTOLOAD')) {
define('DOMPDF_ENABLE_AUTOLOAD', false);
}
if (file_exists($configPath = base_path().'/vendor/dompdf/dompdf/dompdf_config.inc.php')) {
require_once $configPath;
}
$dompdf = new \DOMPDF;
$dompdf->load_html($this->view($data)->render());
$dompdf->render();
return $dompdf->output();
}
Actually, I figured it out on my own. Im running the latest build of Laravel framework with Dompdf/Dompdf 0.7.0 installed. I tried to change Dompdf version to 0.6.1, and some how it did the trick.
If anyone got an explanation on why it won't work with the newest version of dompdf, feel free to explain :-)
If it helps, I believe it's because that version of Dompdf changes the location of that class in 0.7.0 and 0.8.0. This is updated in later versions of Laravel and consequently Cashier EG Laravel 5.4.
For Laravel 5.2, Dompdf 0.6.0 and up should work fine as you say as Cashier knows where the Dompdf class is living :)