Laravel 4 issues with php headers and returning downloads in controller -


i'm using knplabs snappy pdf library generate pdf in laravel 4. works excellently when explicitly put code in routes.php file, when route controller , method code no longer works? missing something, or there more need if executing code in controller.

route 'test1' works expected, route 'test2' refreshes browser , shows nothing, not errors.

route.php

<?php  route::get('test1', function() {     $pdf = new knp\snappy\pdf('/path/to/vendor/google/wkhtmltopdf-amd64/wkhtmltopdf-amd64');     $headers = array(         'content-type' => 'application/pdf',         'content-disposition' => 'attachment; filename="file22.pdf"',     );     return response::make($pdf->getoutputfromhtml('<h1>works!</h1>'), 200, $headers); });  route::group(array('prefix' => 'trial'), function() {     route::get('test2', 'mycontroller@download'); }); 

mycontroller.php

<?php  class mycontroller extends \basecontroller {       public function download()     {         $pdf = new knp\snappy\pdf('/path/to/vendor/google/wkhtmltopdf-amd64/wkhtmltopdf-amd64');         $headers = array(             'content-type' => 'application/pdf',             'content-disposition' => 'attachment; filename="file22.pdf"',         );         return response::make($pdf->getoutputfromhtml('<h1>works!</h1>'), 200, $headers);     } } 

solved. reason contents of download() method doesn't work if it's being specified in either route::resource() or route::group().

when explicitly state route on it's own works fine.

like this: route::get('trial/test2', 'mycontroller@download');

i've got no idea why is, if else can shed light on reasoning behind this, i'd interested.


Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -