get('/', [MainController::class, 'actionIndex']); $router->get('/example', [MainController::class, 'actionExample']); $router->group(["prefix" => "admin"], function (RouteCollector $router){ $router->group(["prefix" => "user"], function (RouteCollector $router){ $router->get('/create', [\app\controllers\UserController::class, 'actionCreate']); $router->get('/update', [\app\controllers\UserController::class, 'actionUpdate']); $router->get('/delete/{id}', [\app\controllers\UserController::class, 'actionDelete']); $router->get('/', [\app\controllers\UserController::class, 'actionIndex']); $router->get('/{id}', [\app\controllers\UserController::class, 'actionView']); $router->post("/", [\app\controllers\UserController::class, 'actionAdd']); $router->post("/edit", [\app\controllers\UserController::class, 'actionEdit']); }); $router->group(["prefix" => "question"], function (RouteCollector $router){ $router->get('/create', [QuestionController::class, 'actionCreate']); $router->get('/update', [QuestionController::class, 'actionUpdate']); $router->get('/delete/{id}', [QuestionController::class, 'actionDelete']); $router->get('/', [QuestionController::class, 'actionIndex']); $router->get('/{id}', [QuestionController::class, 'actionView']); $router->post("/", [QuestionController::class, 'actionAdd']); $router->post("/edit", [QuestionController::class, 'actionEdit']); }); $router->group(["prefix" => "post"], function (RouteCollector $router){ $router->get('/', [\app\controllers\PostController::class, 'actionIndex']); }); }); $router->get('/allQuestions', [QuestionController::class, 'actionViewAllQuestions']); $router->get('/allAnswers', [AnswerController::class, 'actionViewAllAnswers']); $dispatcher = new Phroute\Phroute\Dispatcher($router->getData()); $response = $dispatcher->dispatch($_SERVER['REQUEST_METHOD'], parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)); // Print out the value returned from the dispatched function echo $response;