In my Joomla 4 component I successfully used the Mpdf library. Since migrating to Joomla 5, the library does not initialise properly. This is the setup that worked in Joomla 4:
class MyModel extends BaseModel
{
public function generatePDF($data)
{
$mpdf = new \Mpdf\Mpdf([]);
...
}
}
The composer.json which loads the Mpdf version working with PHP 8.2 https://mpdf.github.io/about-mpdf/requirements-v7.html:
{
"config": {
"vendor-dir": "admin/vendor",
"platform": {
"php": "8.2.0"
}
}, "require: {
"mpdf/mpdf": "^8.1.3"
}
}
The vendor classes are located in /administrator/components/com_mycomponent/vendor which contains the /autoload.php as well.
In the mycomponent.xml the vendor files are registered like this:
<administration>
<files folder="admin">
...
<folder>vendor</folder>
</files
</administration>
What is the proper way to autoload external libraries in Joomla 5?
Compile Error: Declaration of Mpdf\Mpdf::setLogger(Psr\Log\LoggerInterface $logger) must be compatible with Psr\Log\LoggerAwareInterface::setLogger(Psr\Log\LoggerInterface $logger): void (500 Whoops, looks like something went wrong.)