30 lines
717 B
PHP
30 lines
717 B
PHP
<?php
|
|
|
|
namespace lib\Core;
|
|
|
|
use lib\Core\Router;
|
|
use lib\Http\Response;
|
|
|
|
abstract class App
|
|
{
|
|
protected function __construct()
|
|
{
|
|
// 초기화 작업
|
|
}
|
|
public function run(): void
|
|
{
|
|
$router = new Router();
|
|
require_once ROOT_PATH . DIRECTORY_SEPARATOR . "lib" . DIRECTORY_SEPARATOR . "Configs" . DIRECTORY_SEPARATOR . "Route.php";
|
|
// CLI 요청인지 웹 요청인지에 따라 URI 파싱
|
|
$uri = php_sapi_name() === 'cli' ? $this->parseCliUri() : $_SERVER['REQUEST_URI'];
|
|
$method = php_sapi_name() === 'cli' ? 'GET' : $_SERVER['REQUEST_METHOD'];
|
|
$router->dispatch($uri, $method);
|
|
}
|
|
|
|
private function parseCliUri(): string
|
|
{
|
|
global $argv;
|
|
return $argv[1] ?? '';
|
|
}
|
|
}
|