How to import vendor files in CakePHP 3x

前端 未结 5 1811
庸人自扰
庸人自扰 2020-12-31 05:37

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 thi

5条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-31 06:24

    In cakephp3 , to add a new vendor library you can follow below steps :

    1. Place library folder under your_project/vendor/
    2. include library file using require_once(ROOT . DS . 'vendor' . DS . "my_library_folder" . DS . "my_library_base_class.php") ,this includes the library code file in our code.
    3. Include class name in top of Controller like :

    namespace App\Controller; use MyLibraryBaseClass; ,

    this imports the library code file in our namespace to be used.

    1. create object of loaded class as

      $my_obj= new MyLibraryBaseClass();

提交回复
热议问题