backend/index.php

31 lines
1.1 KiB
PHP
Raw Normal View History

2024-07-03 14:41:15 +03:00
<?php
require_once "vendor/autoload.php";
require 'bootstrap.php';
2024-07-03 15:15:59 +03:00
use app\controllers\MainController;
2024-07-05 13:49:04 +03:00
use app\controllers\Users;
use app\controllers\Questions;
use app\controllers\Answers;
use app\controllers\Posts;
2024-07-03 14:41:15 +03:00
use Phroute\Phroute\RouteCollector;
2024-07-03 15:15:59 +03:00
$router = new RouteCollector();
$router->get('/', [MainController::class, 'actionIndex']);
$router->get('/example', [MainController::class, 'actionExample']);
2024-07-05 13:49:04 +03:00
//$router->get('/createUser', [Users::class, 'actionCreateUser']);
$router->get('/allUsers', [Users::class, 'actionViewAllUsers']);
$router->get('/User', [Users::class, 'actionViewUser'], ['3']);
$router->get('/allQuestions', [Questions::class, 'actionViewAllQuestions']);
$router->get('/allPosts', [Posts::class, 'actionViewAllPosts']);
$router->get('/allAnswers', [Answers::class, 'actionViewAllAnswers']);
2024-07-03 15:15:59 +03:00
$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;