问题
After updating composer with required packages and registering in config/app.php, I've tried laravel-fpdf in laravel 5.3,
composer.json
"require": {
.....
"codedge/laravel-fpdf": "^1.0"
},
providers
Codedge\Fpdf\FpdfServiceProvider::class,
aliases
'Fpdf' => Codedge\Fpdf\Facades\Fpdf::class,
simply in web.php routes like
Route::get('GeneratePdf', function (Codedge\Fpdf\Fpdf\FPDF $fpdf) {
$fpdf->AddPage();
$fpdf->SetFont('Courier', 'B', 18);
$fpdf->Cell(50, 25, 'Hello World!');
$fpdf->Output();
}); And I'm getting error Class Codedge\Fpdf\Fpdf\FPDF does not exist
What could possibly be wrong ?
回答1:
Try to remove service provider and alias from config/app.php, then run:
composer update
php artisan vendor:publish --provider="Codedge\Fpdf\FpdfServiceProvider" --tag=config
composer dumpauto
Then add service provider and alias back to config/app.php.
回答2:
The class name changed from Codedge\Fpdf\Fpdf\FPDF to Codedge\Fpdf\Fpdf\Fpdf
The function name changed. So you can update the previous to use Codedge\Fpdf\Fpdf\Fpdf;
回答3:
make sure you rename the file fpdf.php in src/Fpdf so that it start with a capital letter
来源:https://stackoverflow.com/questions/40559827/laravel-5-3-codedge-laravel-fpdf-class-not-found