PHP: class not found even with using namespace

落花浮王杯 提交于 2020-01-15 03:31:09

问题


I'm trying to execute a php script with ajax but I get this error Fatal error: Class 'backoffice\controllers\TypesManager' not found although I used namespace.
This is the php file that I called it from ajax function:

namespace backoffice\controllers;
use backoffice\controllers\TypesManager;

$tm = new TypesManager();
echo $tm->getAllTypes();

And this is the my TypesManager class:

namespace backoffice\controllers;


/**
 * TypesManager
 */
class TypesManager{

    function __construct(){

    }

    public function getAllTypes(){
        echo 'Display all types.';
    }
}

Both classes are under this path: backoffice/controller.
What am I missing here ?

来源:https://stackoverflow.com/questions/35268022/php-class-not-found-even-with-using-namespace

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