We are moving our forum in GitHub Discussions. For questions about Phalcon v3/v4 you can visit here and for Phalcon v5 here.

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?


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


$loader = new \Phalcon\Loader();

        "PHPMailer"         => "library/PHPMailer/PHPMailer.php",

// register autoloader


... 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.