firstPHP/index.php

44 lines
2.6 KiB
PHP
Raw Normal View History

2024-03-15 14:17:25 +03:00
<?php
2024-03-20 18:31:49 +03:00
ini_set("display_errors", 1);
2024-03-15 14:17:25 +03:00
error_reporting(-1);
2024-03-25 18:07:54 +03:00
const ROOT_PATH = __DIR__;
2024-04-05 18:47:38 +03:00
const BASE_URL = "http://forms.local";
2024-03-25 18:07:54 +03:00
const VIEW_PATH = __DIR__ . "/views";
const VIEW_CACHE_PATH = __DIR__ . "/compilation_cache";
2024-03-15 16:56:03 +03:00
require_once "vendor/autoload.php";
2024-03-15 14:17:25 +03:00
2024-03-25 18:07:54 +03:00
require_once "bootstrap/db.php";
2024-03-20 18:31:49 +03:00
use Phroute\Phroute\RouteCollector;
2024-03-15 16:56:03 +03:00
2024-03-20 18:31:49 +03:00
$router = new RouteCollector();
2024-03-15 16:56:03 +03:00
2024-03-25 18:07:54 +03:00
$router->get('/', [\itguild\forms\app\controllers\MainController::class, 'indexAction']);
$router->get('/example', [\itguild\forms\app\controllers\MainController::class, 'exampleAction']);
$router->get('/create-user', [\itguild\forms\app\controllers\UserController::class, 'createUserAction']);
$router->get('/get-user/{id}', [\itguild\forms\app\controllers\UserController::class, 'getUserAction']);
2024-03-29 17:47:46 +03:00
$router->get("/form/{id}", [\itguild\forms\app\controllers\FormController::class, "indexAction"]);
$router->get("/form-input/{id}", [\itguild\forms\app\controllers\FormInputController::class, "indexAction"]);
$router->get("/form-res/{id}", [\itguild\forms\app\controllers\FormResController::class, "indexAction"]);
$router->get("/input-type/{id}", [\itguild\forms\app\controllers\InputTypeController::class, "indexAction"]);
$router->get("/input-value/{id}", [\itguild\forms\app\controllers\InputValueController::class, "indexAction"]);
2024-04-01 17:56:37 +03:00
$router->post("/form-save/{id}", [\itguild\forms\app\controllers\FormController::class, "saveAction"]);
2024-04-15 17:46:33 +03:00
$router->get("/form-result/{id}/{page}?", [\itguild\forms\app\controllers\FormController::class, "resultAction"]);
$router->get("/form-item/{id}", [\itguild\forms\app\controllers\FormController::class, "viewAction"]);
$router->get("/form-delete/{id}", [\itguild\forms\app\controllers\FormController::class, "deleteAction"]);
$router->get("/form-edit/{id}", [\itguild\forms\app\controllers\FormController::class, "editAction"]);
$router->get("/admin/create-form", [\itguild\forms\app\controllers\AdminController::class, "createAction"]);
2024-05-03 18:11:43 +03:00
$router->post("/admin/save-form/", [\itguild\forms\app\controllers\AdminController::class, "saveFormAction"]);
2024-04-17 17:30:00 +03:00
$router->get("/admin/form-add-fields", [\itguild\forms\app\controllers\AdminController::class, "getFormAddFieldsAction"]);
$router->get("/admin/set-value-select", [\itguild\forms\app\controllers\AdminController::class, "getSelectValue"]);
2024-05-02 17:52:03 +03:00
$router->get("/admin/edit-form/{id}", [\itguild\forms\app\controllers\AdminController::class, "editFormAction"]);
2024-03-20 18:31:49 +03:00
$dispatcher = new Phroute\Phroute\Dispatcher($router->getData());
2024-03-15 17:54:06 +03:00
2024-03-20 18:31:49 +03:00
$response = $dispatcher->dispatch($_SERVER['REQUEST_METHOD'], parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH));
2024-03-18 17:52:16 +03:00
2024-03-25 18:07:54 +03:00
2024-03-20 18:31:49 +03:00
// Print out the value returned from the dispatched function
echo $response;