Slim3 告诉我找不到可调用路由

Slim3 telling me that callable route can't be found

我是瘦身新手。我 运行 遇到一个错误,告诉我可调用控制器不存在。但是我的其他控制器 (HomeController) 确实有效。我确定我在做一些愚蠢的事情,但我不知道是什么。

错误信息

Type: RuntimeException
Message: Callable JoeyD473\RPG_Tools\controllers\traveller\UniverseCreationControllercreateUniverse does not exist
File: C:\Users\Joey\Web\JRD_Traveller_Tools\vendor\slim\slim\Slim\CallableResolver.php

Line: 90

项目结构

\public
    index.php
    .htaccess
\src
    \app
        \controllers
            BaseController.php
            HomeController.php
            \traveller
                UniverseCreationController.php
        \model
        \views
         config.php
         container.php
         routes.php

composer.json

"autoload": {
    "psr-4": {
        "JoeyD473\RPG_Tools\models\": "src/app/model",
        "JoeyD473\RPG_Tools\controllers\": "src/app/controllers"
    }
},

container.php

$container = $app->getContainer();

$container['view'] = new \Slim\Views\PhpRenderer(APP.'views/');

$container['db'] = function($c){
    $settings = $c->get('settings')['db'];

    $db = new \Aura\Sql\ExtendedPdo($settings['vendor'].':host='.$settings['host'].';dbname='.$settings['db_name'],$settings['username'],$settings['password']);

    return $db;
};

$container['HomeController'] = function($container){
    return new \JoeyD473\RPG_Tools\controllers\HomeController;
};

$container['UniverseCreationController'] = function($container){
    return new \JoeyD473\RPG_Tools\controllers\traveller\UniverseCreationController;
};

routes.php

$app->get('/',JoeyD473\RPG_Tools\controllers\HomeController::class.':home');

$app->get('/api',JoeyD473\RPG_Tools\controllers\HomeController::class.':sw_api');

$app->get('/temp',JoeyD473\RPG_Tools\controllers\HomeController::class.':temp');

$app->get('/universe/create_new_universe',JoeyD473\RPG_Tools\controllers\traveller\UniverseCreationController::class.'createUniverse');

UniverseCreationController.php

namespace JoeyD473\RPG_Tools\controllers\traveller;

use JoeyD473\RPG_Tools\controllers\BaseController;
use JoeyD473\RPG_Tools\models\traveller\universe\Universes;

class UniverseCreationController extends BaseController
{
    public function createUniverse($request,$response)
    {
        return $this->container->view->render($response,'travellers/universe/create_universe.phtml');
    }

    public function generateUniverse($request,$response)
    {
        $universe = new Universes($this->db);
        return 'generateSector';
    }
}

您在上一条路线中漏掉了一个冒号 (:)

\traveller\UniverseCreationController::class.'createUniverse');
                                           ^^^

您也可以为此使用数组语法。

[YourClass::class, 'yourMethod']