title: Export PDF in Laravel with so much data
body: <p>I have the next code</p>
  
  <pre><code>$html = '';
  foreach ($posts as $post) {
          $html .= '&lt;div class="table-scrollable"&gt;
                          &lt;table id="posts" class="table table-bordered table-hover"&gt;
                              &lt;thead&gt;
                                  &lt;tr&gt;
                                      &lt;th&gt;Id&lt;/th&gt;
                                      &lt;th&gt;Name&lt;/th&gt;
                                      &lt;th&gt;Title&lt;/th&gt;
                                  &lt;/tr&gt;
                              &lt;/thead&gt;
                              &lt;tbody id="body"&gt;&lt;tr&gt;
                                  &lt;td&gt;'
                  . $post-&gt;id . ' 
                                  &lt;/td&gt;
                                  &lt;td&gt;' .
                  $post-&gt;name .
                  '&lt;/td&gt;
                                  &lt;td&gt;'
                  . $post-&gt;title .
                  '&lt;/td&gt; 
                      &lt;/tr&gt;
                     &lt;/tbody&gt;
                  &lt;/table&gt;
              &lt;/div&gt;';
  }
  return PDF::load($html, 'A4', 'portrait')-&gt;download('my_pdf');
  </code></pre>
  
  <p>The problem is when I want to download so much data i'm getting the next error <code>The localhost page isn’t working localhost is currently unable to handle this request.</code> But if I try to download for example 20 entry, works fine. What can I do?</p>
  
  <p>laravel.log</p>
  
  <blockquote>
    <p>[2016-11-24 13:15:17] production.ERROR: exception 'ErrorException'
    with message 'Undefined variable: data_start' in
    /Applications/XAMPP/xamppfiles/htdocs/dicom/app/controllers/IncasariController.php:58
    Stack trace:</p>
    
    <h1>0 /Applications/XAMPP/xamppfiles/htdocs/dicom/app/controllers/IncasariController.php(58):</h1>
    
    <p>Illuminate\Exception\Handler->handleError(8, 'Undefined varia...',
    '/Applications/X...', 58, Array)</p>
    
    <h1>1 [internal function]: IncasariController->filtrareChitante()</h1>
    
    <h1>2 /Applications/XAMPP/xamppfiles/htdocs/dicom/vendor/laravel/framework/src/Illuminate/Routing/Controller.php(231):</h1>
    
    <p>call_user_func_array(Array, Array)</p>
    
    <h1>3 /Applications/XAMPP/xamppfiles/htdocs/dicom/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(93):</h1>
    
    <p>Illuminate\Routing\Controller->callAction('filtrareChitant...', Array)</p>
    
    <h1>4 /Applications/XAMPP/xamppfiles/htdocs/dicom/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(62):</h1>
    
    <p>Illuminate\Routing\ControllerDispatcher->call(Object(IncasariController),
    Object(Illuminate\Routing\Route), 'filtrareChitant...')</p>
    
    <h1>5 /Applications/XAMPP/xamppfiles/htdocs/dicom/vendor/laravel/framework/src/Illuminate/Routing/Router.php(962):</h1>
    
    <p>Illuminate\Routing\ControllerDispatcher->dispatch(Object(Illuminate\Routing\Route),
    Object(Illuminate\Http\Request), 'IncasariControl...',
    'filtrareChitant...')</p>
    
    <h1>6 [internal function]: Illuminate\Routing\Router->Illuminate\Routing{closure}()</h1>
    
    <h1>7 /Applications/XAMPP/xamppfiles/htdocs/dicom/vendor/laravel/framework/src/Illuminate/Routing/Route.php(109):</h1>
    
    <p>call_user_func_array(Object(Closure), Array)</p>
    
    <h1>8 /Applications/XAMPP/xamppfiles/htdocs/dicom/vendor/laravel/framework/src/Illuminate/Routing/Router.php(1028):</h1>
    
    <p>Illuminate\Routing\Route->run(Object(Illuminate\Http\Request))</p>
    
    <h1>9 /Applications/XAMPP/xamppfiles/htdocs/dicom/vendor/laravel/framework/src/Illuminate/Routing/Router.php(996):</h1>
    
    <p>Illuminate\Routing\Router->dispatchToRoute(Object(Illuminate\Http\Request))</p>
    
    <h1>10 /Applications/XAMPP/xamppfiles/htdocs/dicom/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(775):</h1>
    
    <p>Illuminate\Routing\Router->dispatch(Object(Illuminate\Http\Request))</p>
    
    <h1>11 /Applications/XAMPP/xamppfiles/htdocs/dicom/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(745):</h1>
    
    <p>Illuminate\Foundation\Application->dispatch(Object(Illuminate\Http\Request))</p>
    
    <h1>12 /Applications/XAMPP/xamppfiles/htdocs/dicom/vendor/laravel/framework/src/Illuminate/Session/Middleware.php(72):</h1>
    
    <p>Illuminate\Foundation\Application->handle(Object(Illuminate\Http\Request),
    1, true)</p>
    
    <h1>13 /Applications/XAMPP/xamppfiles/htdocs/dicom/vendor/laravel/framework/src/Illuminate/Cookie/Queue.php(47):</h1>
    
    <p>Illuminate\Session\Middleware->handle(Object(Illuminate\Http\Request),
    1, true)</p>
    
    <h1>14 /Applications/XAMPP/xamppfiles/htdocs/dicom/vendor/laravel/framework/src/Illuminate/Cookie/Guard.php(51):</h1>
    
    <p>Illuminate\Cookie\Queue->handle(Object(Illuminate\Http\Request), 1,
    true)</p>
    
    <h1>15 /Applications/XAMPP/xamppfiles/htdocs/dicom/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23):</h1>
    
    <p>Illuminate\Cookie\Guard->handle(Object(Illuminate\Http\Request), 1,
    true)</p>
    
    <h1>16 /Applications/XAMPP/xamppfiles/htdocs/dicom/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(641):</h1>
    
    <p>Stack\StackedHttpKernel->handle(Object(Illuminate\Http\Request))</p>
    
    <h1>17 /Applications/XAMPP/xamppfiles/htdocs/dicom/public/index.php(49): Illuminate\Foundation\Application->run()</h1>
    
    <h1>18 {main} [] []</h1>
  </blockquote>
  
  <p>And on webpage is: </p>
  
  <pre><code>The localhost page isn’t working
  
  localhost is currently unable to handle this request.
  </code></pre>