Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CakePHP 3.0 vendor class not found

I'm adding an external class to a cake 3.0 app by putting it to /vendor/name folder and requiring it from a component like this:

require_once( $_SERVER['DOCUMENT_ROOT'].'/project/vendor/external/testClass.php');

But when I try to getInstance(); of a class - I get an error

Class 'App\Controller\Component\Test_Class' not found 

I am calling this from a component (thus the \Controller\Component).

What is it that i'm doing wrong?

like image 804
Kristis Avatar asked Apr 08 '26 08:04

Kristis


1 Answers

CakePHP 3.0 uses namespaces. So use proper namespace for your vendor class or if it's not using namespaces prefix the class name with backslash when using it.

E.g. $object = new \Test_Class();.

like image 66
ADmad Avatar answered Apr 10 '26 21:04

ADmad