找不到 CakePHP 3.0 供应商类 [英] CakePHP 3.0 vendor class not found

查看:29
本文介绍了找不到 CakePHP 3.0 供应商类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将一个外部类添加到 cake 3.0 应用程序中,方法是将其放入/vendor/name 文件夹并从这样的组件中要求它:

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');

但是当我尝试 getInstance();一个班级 - 我收到一个错误

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

Class 'AppControllerComponentTest_Class' not found 

我从一个组件(因此是 ControllerComponent)调用它.

I am calling this from a component (thus the ControllerComponent).

我做错了什么?

推荐答案

CakePHP 3.0 使用命名空间.因此,请为您的供应商类使用适当的命名空间,或者如果它不使用命名空间,则在使用它时用反斜杠作为类名的前缀.

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.

例如$object = new Test_Class();.

这篇关于找不到 CakePHP 3.0 供应商类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆