Search code examples
phplaravel-5composer-phpfpdffpdi

Trying to include setasign/fpdf via composer


I'm trying to include fpdf and fpdi via installing setasign/fpdi-fpdf through composer but I can't seem to get fpdf or fpdi loaded. The error I get is Class 'setasign\fpdf\FPDF' not found.

use \setasign\fpdf\FPDF as FPDF;

//inside controller function
fpdf::AddPage();
fpdf::SetFont('Courier', 'B', 18);
fpdf::Cell(50, 25, 'Hello World!');
fpdf::Output();

Maybe I should be adding something to the config/app.php file in order to load the classes?


Solution

  • FPDF is not namespaced. The package is a clone of the original release with an additional composer.json file. Nothing more.

    Just use \FPDF if you want to use the FPDF class.

    The latest FPDI release is namespaced: \setasign\Fpdi\Fpdi

    Additionally you should/cannot call the methods static.