We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

FPDF With PhalconPHP. thanks in advance.

Inside CentrosController at the end ...

    public function createPdfAction() {
        global $config;

        $loader = new \Phalcon\Loader();

        $loader->registerDirs(
            array(
                $config->application->libraryDir."fpdf/"
            )   
        );
        echo $config->application->libraryDir."fpdf/";  // this is Ok.
        $loader->register();

        $pdf = new FPDF();
    }

PHP Error .>Fatal error: Class 'FPDF' not found in C:\wamp\www\ph_rosaleda\app\controllers\CentrosController.php on line 253

edited Mar '14

Use from composer:

{
    "require": {
       "itbz/fpdf": "dev-master"
    }
}

and in index.php:

require 'vendor/autoload.php';


7.4k
edited Mar '14

Thanks, Is working correctly but i do it by the index.php:

    $loader = new \Phalcon\Loader();
    $loader->registerDirs(
        array(
            __DIR__ . $config->application->controllersDir,
            __DIR__ . $config->application->pluginsDir,
            __DIR__ . $config->application->libraryDir,
            __DIR__ . $config->application->modelsDir,
            __DIR__ . $config->application->libraryDir."fpdf/",
        )
    )->register();

I think i need learn more about autoload and composer. It's enough for a beginner. Thank and sorry by my english.