How to import vendor files in CakePHP 3x

G.J picture G.J · Oct 25, 2014 · Viewed 30.6k times · Source

I'm working with CakePHP 3(beta 2) version recently launched. I need to integrate Facebook Login using PHP SDKs and I'm not clear with importing vendor files in this version.
In CakePHP 2x, I had used

App::import('Vendor', 'Facebook', array('file' => 'Facebook' . DS . 'src'. DS. 'facebook.php'));

So I need to reproduce the same in CakePHP 3x(I'm not using composer).
Any reference for this?

Answer

Ayman Bedair picture Ayman Bedair · Oct 25, 2014

Well you will have to load it yourself if composer is not an option. You can always use the very basic require method and create a new instance of the vendor class yourself. Reference: http://book.cakephp.org/3.0/en/core-libraries/app.html#loading-vendor-files

Use:

 //The following line should do the same like App::import() in the older version of cakePHP
 require_once(ROOT . 'vendor' . DS  . 'Facebook' . DS . 'src' . DS . 'facebook.php');

 $facebookApi = new facebook();