32 lines
796 B
PHP
32 lines
796 B
PHP
<?php
|
|
|
|
spl_autoload_register(function ($class) {
|
|
$prefix = 'App\\';
|
|
$base_dir = __DIR__ . '/app/';
|
|
|
|
$len = strlen($prefix);
|
|
if (strncmp($prefix, $class, $len) !== 0) {
|
|
return;
|
|
}
|
|
|
|
$relative_class = substr($class, $len);
|
|
$file = $base_dir . str_replace('\\', '/', $relative_class) . '.php';
|
|
|
|
if (file_exists($file)) {
|
|
require $file;
|
|
}
|
|
});
|
|
|
|
use App\Core\Router;
|
|
|
|
$router = new Router();
|
|
|
|
// Routes
|
|
$router->add('GET', '/', ['App\Controllers\HomeController', 'index']);
|
|
$router->add('GET', '/apk/{slug}', ['App\Controllers\ApkController', 'detail']);
|
|
$router->add('GET', '/apk/{slug}/download', ['App\Controllers\ApkController', 'download']);
|
|
|
|
$method = $_SERVER['REQUEST_METHOD'];
|
|
$uri = $_SERVER['REQUEST_URI'];
|
|
|
|
$router->dispatch($method, $uri); |