Search code examples
cakephpvendorcakephp-3.0

How to import vendor files in CakePHP 3x


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?


Solution

  • 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();