Search code examples
laravelpdf-generationdompdf

barryvdh/laravel-dompdf doesn't work last version for now


My code doesn't work. I use Laravel framework. Error on the picture. I think maybe it's looping

config/app:

'providers' => [
Barryvdh\DomPDF\ServiceProvider::class,
 ],
 'aliases' => [
 'PDF' => Barryvdh\DomPDF\Facade::class,
 ],

web.php //routes:

Route::get('/', function () { //Авторизация
  return view('auth.authorize');
})->name('/');
Route::namespace('App\Http\Controllers')->group(function () { 
  Route::post('/auth', 'AuthController@auth');  
  Route::middleware('auth')->group(function () {  
    Route::get('/layouts', function () { 
      return view('layouts.app');
    });
    Route::get('/logout', 'AuthController@logout'); 
    Route::get('/deals/preview/{id}', 'DealsController@preview')->name('deals.preview'); //this
    Route::get('/deals/generate/{id}', 'DealsController@generatePDF')->name('deals.generate'); //this

My controller:

use PDF;
class DealsController extends Controller
{...
public function generatePDF($id)
    {
        $application_form = Application_form::find($id);
        $pdf = PDF::loadView('deals.show', ['application_form'=>$application_form]);
       return $pdf->download('demo.pdf');       
    }...
}

my blade show.blade.php:

 <a href="{{ route('deals.generate', ['id' => $application_form->id]) }}" class="btn btn-primary">Generation to pdf
          <i class="fa fa-pencil-square"></i>
        </a> 

It's my error. Laravel doesn't generate my PHP-HTML page.

It's my error laravel don't generate my php-html page


Solution

  • The Maximum execution time error is related to your PHP configuration, It isn't related to Laravel. Open php.ini change the max_execution_time to 300 seconds. Like this:

    max_execution_time = 300
    

    The other way is that you can increase the execution time limit only for specific php scripts, by inserting one of the following codes on top of your php file. Like this:

    ini_set('max_execution_time', 300);
    

    Or

    set_time_limit(0);