fritz
fritz

Reputation: 329

cakephp 2.3.0 failed to load vendor files

I am having problems loading vendor files in cakephp 2.3.0. I have tried entering App::import('Vendor', 'EncodingProfileConfig'); just above App::uses('AppController', 'Controller'); in my StreamsController.php file. I get the error "class 'EncodingProfileConfig' not found". How do I solve this? I was using this Reference: https://book.cakephp.org/2.0/en/core-utility-libraries/app.html#loading-vendor-files

The actual class is inside app/Vendor/bitcodin/lib directory. But after this code below failed, I tried a more straightforward approach which the above. Which failed too. What I am really trying to do is to load it without removing it in it's directory app/Vendor/bitcodin/lib.

App::build(array('Vendor' => array(APP . 'Vendor' . DS . 'bitcodin' . DS . 'lib' . DS)));
App::uses('EncodingProfileConfig', 'Vendor/bitcodin');

Upvotes: 0

Views: 915

Answers (2)

beta-developper
beta-developper

Reputation: 1774

Use the import by specifying the file location in parameters

App::import('Vendor', 'EncodingProfileConfig', array('file' => 'bitcodin' . DS . 'lib' . DS . 'EncodingProfileConfig.php' ));
// Add this line to import the class from the namespace
use bitcodin\EncodingProfileConfig;

Insert this code before using the class EncodingProfileConfig or in the begining of your file, just after App::uses('AppController', 'Controller');

Upvotes: 0

Ajay Dhul
Ajay Dhul

Reputation: 1

Use this

App::import('Vendor', 'filename');

if your file is in some folder inside vendor then specify folder before filename like App::import('Vendor', 'foldername/filename'); In your case

App::import('Vendor', 'bitcodin/lib/filename');

Upvotes: 0

Related Questions