Kristis
Kristis

Reputation: 409

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?

Upvotes: 2

Views: 3814

Answers (1)

ADmad
ADmad

Reputation: 8100

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

Upvotes: 10

Related Questions