How i can add external library to phalcon project?

I want to add PHPMailer to my phalcon-project. I put PHPMailer-dir to library-dir. How a can create object PHPMailer without "require" with full path to file?



81.2k

If PHPMailer is PSR-0 compliant you can use a namespaces/directories strategy, or map the class name directly to its path:

<?php

$loader = new \Phalcon\Loader();

$loader->registerClasses(
    array(
        "PHPMailer"         => "library/PHPMailer/PHPMailer.php",
    )
);

// register autoloader
$loader->register();

http://docs.phalconphp.com/en/latest/reference/loader.html#registering-classes

... and if not, you still add it as suggested and map all underlying classes as well :-) Easy as a pie.

And you leave a note to the author of the library to (finally) make his library PSR-0 compliant.