dima887
Новичок
Помогите разобраться почему не находит страницу...
index.php
routes.php
Router.php
index.php
PHP:
require_once __DIR__ . "/vendor/autoload.php";
require_once __DIR__ . "/router/routes.php";
PHP:
use App\Services\Router;
Router::page(uri: '/test', page_name: 'test');
Router::page(uri: '/test2', page_name: 'test2'); Router::enable();
PHP:
namespace App\Services;
class Router
{
private static array $list = [];
public static function page($uri, $page_name)
{
self::$list[] = [
"uri" => $uri,
"page" => $page_name
];
}
public static function enable()
{
$query = $_GET['q'];
foreach (self::$list as $route) {
if ($route["uri"] === '/' . $query) {
require_once "views/pages/" . $route['page'] . ".php";
}
}
}
}