title: Laravel, view to PDF using DomPDF
body: <p><strong>Scenario</strong>: I am currently trying to convert a Laravel view to pdf so that the user can have a pdf version of their profile page.</p>
  
  <p><strong>Info</strong>: I am using Laravel cashier which apparently comes with dompdf to create invoices. I found this out when trying to do </p>
  
  <blockquote>
    <p>composer require dompdf/dompdf</p>
  </blockquote>
  
  <p>. The Error message was </p>
  
  <blockquote>
    <p>laravel/cashier v6.0.18 requires dompdf/dompdf ^0.6.1 -> satisfiable
    by dompdf/dompdf[v0.6.1, v0.6.2] but these conflict with your
    requirements or minimum-stability</p>
  </blockquote>
  
  <p>Also found out from the Laravel cashier documentation: <a href="https://laravel.com/docs/5.4/billing#generating-invoice-pdfs" rel="nofollow noreferrer">https://laravel.com/docs/5.4/billing#generating-invoice-pdfs</a></p>
  
  <p>So I am using dompdf v0.6 I imagine.</p>
  
  <p><strong>Problem</strong>: I try using dompdf as normal since I think I have it setup from Laravel cashier. But I am getting many errors in my controller when trying to use any functionality from dompdf, if I try:</p>
  
  <pre><code>use Dompdf;
  
  // instantiate and use the dompdf class
  $dompdf = new Dompdf();
  $dompdf-&gt;loadHtml('hello world');
  
  // (Optional) Setup the paper size and orientation
  $dompdf-&gt;setPaper('A4', 'landscape');
  
  // Render the HTML as PDF
  $dompdf-&gt;render();
  
  // Output the generated PDF to Browser
  $dompdf-&gt;stream();
  </code></pre>
  
  <p>I get an error saying that class Dompdf is not defined. so If I try to use Laravel cashier functionality for their "pdf conversion for invoices" like so:</p>
  
  <pre><code>$pdf = downloadInvoice::loadView('dashboard.index', ['user' =&gt; $user]);
      return $pdf-&gt;download('profile.pdf');
  </code></pre>
  
  <p>Then I get an error saying that </p>
  
  <blockquote>
    <p>Class 'App\Http\Controllers\downloadInvoice' not found</p>
  </blockquote>
  
  <p>I tried Googling a lot but I am really lost at this point, can someone be so kind to point a lost developer in the right direction? :) Thank you for your time in advnaced!</p>
  
  <p><strong>EDIT</strong>: I tried: </p>
  
  <p><code>$pdf = PDF::loadView('dashboard.index', ['user' =&gt; $user]);
      return $pdf-&gt;download('profile.pdf');</code></p>
  
  <p>but get </p>
  
  <blockquote>
    <p>Class 'App\Http\Controllers\PDF' not found</p>
  </blockquote>
  
  <p>It looks like dompdf is not even being reconginzed. Is there a away I can look into this and see if this thing is working properly?</p>