0

我尝试使用PatrickLouys/no-framework-tutorial My Controllers/BaseController.php 构建测试项目:

<?php

namespace Example\Controllers;

class BaseController
{
    public function test(){
        echo 'test';
    }
}

和 index.php 文件:

<?php

namespace Example;

require __DIR__.'/vendor/autoload.php';

// come code with routes

case \FastRoute\Dispatcher::FOUND:
        $className = $routeInfo[1][0];
        $method = $routeInfo[1][1];
        $vars = $routeInfo[2];

        $class = new $className; <-- load the class specified in the routes
        $class->$method($vars);
        break;

// some code

当我尝试运行此代码时,出现错误:

找不到类“示例\控制器\BaseController”

你能告诉我我在哪里做错了吗?

4

0 回答 0