daveh / php-mvc

A simple PHP model-view-controller framework, built step-by-step as part of the "Write PHP like a pro: build an MVC framework from scratch" course on Udemy.
https://davehollingworth.com/go/phpmvc/
MIT License
782 stars 311 forks source link

add pdfdom to framework #104

Closed roobiniano closed 2 years ago

roobiniano commented 2 years ago

Hi dave, how are you?

i have a question to you, if you can answer that, i`ll be realy graitful

And the question is .... ¿How is the correct way to add de DomPdf library to the framework?

I just run composer require dompdf/dompdf in the app directory and composer install the library in vendor/dompdf, and i try to access from a an app controller in this way but its not working:

`

<?php

namespace App\Controllers;

use \Core\View;
use \App\Config;
use \Dompdf\Dompdf;

class Escritos extends \Core\Controller
{
    public function generarPDF () 
    {

         // instantiate and use the dompdf class
    $dompdf = new Dompdf();
     }
}

` that give a:

Fatal error Uncaught exception: 'Error'

Message: 'Class 'Dompdf\Dompdf' not found'

greatings!

daveh commented 2 years ago

Hi - you have to run the composer require command in the root folder, not the App folder - that way the package will be included in the vendor folder in the root, and including Composer's autoloader in the front controller will include the package's files automatically.