Wildchild
Wildchild

Reputation: 243

Import a library with CakePHP

I am using CakePHP (v3.0), and my Controller code is as below:

namespace App\Controller;

class ArticlesController extends AppController{

    public function index(){
        $context = new BLTI("secret", true, false);
    }
}

I want to create a BLTI object. I have a folder whose name is ims that contains the following PHP files:

I have placed this ims folder in vendor directory. My problem is that i don't know how I must import this ims folder in my Controller to use it.

Upvotes: 2

Views: 770

Answers (1)

floriank
floriank

Reputation: 25698

App::import() has been removed in CakePHP 3.0, so simply require() the files and use the use statement to load the classes into your namespace.

Normally you would just add them to your autoloader, but obviously these files and classes are pretty old and don't care about best practice (one class per file) or follow any convention for automated file loading.

You could change the files naming of that lib as well so that they can be used with the autoloader. Should be easy to do as well.

Upvotes: 1

Related Questions