Thursday, September 22, 2016

Allowed memory size of 268435456 bytes exhausted

This is due to default memory limit in PHP

Locate PHP.ini file
php --ini

find memory_limit and set to 2048M

Tuesday, September 6, 2016

Generating PDF file from html

You need to download and install wkhtmltopdf exe file
http://wkhtmltopdf.org/downloads.html#stable

then use laravel wrapper
Add the following line in the required
"barryvdh/laravel-snappy": "0.2.*"

After updating composer, add the ServiceProvider to the providers array in app/config/app.php
Barryvdh\Snappy\ServiceProvider::class,
You can optionally use the facade for shorter code. Add this to your facades:
'PDF' => Barryvdh\Snappy\Facades\SnappyPdf::class,
'SnappyImage' => Barryvdh\Snappy\Facades\SnappyImage::class,
Using the wrapper:
$pdf = App::make('snappy.pdf.wrapper');
$pdf->loadHTML('<h1>Test</h1>');
return $pdf->inline();
Or use the facade:
$pdf = PDF::loadView('pdf.invoice', $data);
return $pdf->download('invoice.pdf');
Important : You can publish the config-file to change some settings (default paper etc).
php artisan vendor:publish