Laravel 5.3 codedge/laravel-fpdf Class Not found

心不动则不痛 提交于 2019-12-11 04:43:52

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!