php - Laravel-DomPDF Guzzle GET Request From a CLI -
i want execute dompdf download terminal command. cli command executes api call guzzle. have made simple setup.
problem
500 server error
[guzzlehttp\exception\serverexception]   server error: `get http://localhost:8888/pdf` resulted in `500 internal s   erver error` response:   <!doctype html>   <html>       <head>           <meta charset="utf-8" />           <meta name="robots" content="noindex,nofollow (truncated...)   api call
command
php artisan pdf
project structure
- commands  
- pdfcommand.php
 
 - controller  
- pdfcontroller.php
 
 - views  
- rapport.blade.php
 
 
the sourcecode
route
route::get('pdf', 'pdfcontroller@downloadpdf');   pdfcommand.php
<?php  namespace app\console\commands;  use illuminate\console\command; use guzzlehttp\client guzzleclient;  class pdfcommand extends command {      protected $signature = 'pdf';      protected $description = 'download pdf';      public function __construct()     {         parent::__construct();      }      public function handle()     {         $client = new guzzleclient;         $client->request('get', 'http://localhost:8888/pdf');      } }   pdfcontroller.php
<?php  namespace app\core;  use app\http\controllers\controller; use barryvdh\dompdf\facade pdf;  class pdfcontroller extends controller {      private $pdf;     private $client;      public function downloadpdf()     {         $this->pdf = pdf::loadview('report');         return $this->pdf->download('report.pdf');     }   }   rapport.blade.php
<!doctype html>     <html>         <head>             <title>rapport</title>             </head>             <body>                 <h1>test</h1>                 <p>dit een test</p>             </body>     </html>      
could read error? when receive 500 server error, response contains html error description. should contain explanation what's wrong. save file (file_put_contents('...', $response->getbody()->getcontents())) or read in way.
wiki
Comments
Post a Comment