How to load external library in Phalcon?

3.8k views Asked by At

I'm trying to load Kint into my first Phalcon project. I'm trying to use the loader.php to do so. I tried with "registerDirs", "registerClass" and "registerNamespaces".

I am used to using Kint in Symfony2 via composer but this time I tried to clone the git repo and place it in a vendors folder in this Pahlcon project. All I get when requireing the Kint class is a silent 500 internal error. The following is the code I currently have.

<?php
# app/config/loader.php

$loader = new \Phalcon\Loader();

/**
 * We're a registering a set of directories taken from the configuration file
 */
$loader->registerDirs(
    array(
        $config->application->controllersDir,
        $config->application->modelsDir,
        '~/Code/incubator/Library/Phalcon',
        "vendor/kint"
    )
)->register();

And the controller in question:

<?php
# app/controllers/indexController.php

class IndexController extends ControllerBase
{
    public function indexAction()
    {
        Kint::dump("huh");
    }
}
1

There are 1 answers

0
David Duncan On BEST ANSWER

Require composers autoloader inside of your bootstrap:

Inside your public/index.php, include composers autoloader: https://github.com/phalcon/forum/blob/master/public/index.php#L44

require realpath('..') . "/vendor/autoload.php";