I want to add API routes in my own extension, and I follow tutorial step by step
namespace Flarum\Team\Listener;
use Flarum\Event\ConfigureApiRoutes;
use Flarum\Event\ConfigureForumRoutes;
use Illuminate\Contracts\Events\Dispatcher;
use Flarum\Team\Controllers;
class AddAPiListener
{
public function subscribe(Dispatcher $events)
{
$events->listen(ConfigureApiRoutes::class, [$this, 'configureApiRoutes']);
}
/**
* @param ConfigureApiRoutes $event
*/
public function configureApiRoutes(ConfigureApiRoutes $event)
{
$event->get('/test/hello', 'h', Controllers\TestController::class);
}
}
when i get /api/test/hello,it report an error:
"errors": [
{
"code": 500,
"title": "Internal server error",
"detail": "ReflectionException: Class Flarum\\Team\\Controllers\\TestController does not exist in /home/lrq/code/php/flarum/vendor/illuminate/container/Container.php:
}
]
how to resolve it, thank you very much!