Add initial project structure and configurations

- Set up project directories including app structure.
- Add IntelliJ IDEA project files and configurations.
- Implement basic PHP router for request handling.
- Provide reference files for features, IPs, and documentation.
- Include license and copyright files.
This commit is contained in:
Sapoleone
2025-09-23 23:56:22 +02:00
parent 03cb1c5e13
commit cfaafcffa6
39 changed files with 2950 additions and 1 deletions

47
Router.php Normal file
View File

@@ -0,0 +1,47 @@
<?php
/*
* Copyright (c) 2025. Brusegan Samuele, Davanzo Andrea
* Questo file fa parte di VeyonCtrl ed è rilasciato
* sotto la licenza MIT. Vedere il file LICENSE per i dettagli.
*/
class Router {
private array $routes = [];
// Aggiunge una nuova rotta
public function add($url, $controller, $action): void {
$this->routes[$url] = [
'controller' => $controller,
'action' => $action
];
}
// Smista la richiesta all'azione corretta
public function dispatch($url): void {
$path = rtrim(parse_url($url, PHP_URL_PATH), '/');
if ($path === '') {
$path = '/';
}
if (array_key_exists($path, $this->routes)) {
$route = $this->routes[$path];
$controllerName = $route['controller'];
$actionName = $route['action'];
// Crea il controller e chiama l'azione
$controller = new $controllerName();
$controller->$actionName();
} else {
// Gestione errore 404
header("HTTP/1.0 404 Not Found");
echo "<pre>";
echo "Pagina non trovata!";
echo $path; echo "<br>";
echo $url; echo "<br>";
echo PHP_URL_PATH; echo "<br>";
echo "</pre>";
}
}
}