CakePHP 3.0 vendor class not found

眉间皱痕 提交于 2019-12-18 07:11:13

问题


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?


回答1:


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



来源:https://stackoverflow.com/questions/29866131/cakephp-3-0-vendor-class-not-found

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!