| 1234567891011121314151617181920212223242526272829303132333435363738394041 |
- <?php
- require __DIR__ . '/../vendor/autoload.php';
- $path = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
- $file = __DIR__ . $path;
- if (php_sapi_name() === 'cli-server' && is_file($file)) {
- return false;
- }
- if (class_exists(Dotenv\Dotenv::class) && file_exists(__DIR__ . '/../.env')) {
- Dotenv\Dotenv::createImmutable(
- dirname(__DIR__),
- null,
- true
- )->safeLoad();
- }
- error_reporting(E_ALL);
- use FrameworkX\App;
- use Middlewares\ExternalAuthMiddleware;
- use Libs\ModelFactory;
- try {
- $adb = ModelFactory::adb();
- $GLOBALS['ADB'] = $adb;
- } catch (\Throwable $e) {
- http_response_code(500);
- header('Content-Type: application/json; charset=utf-8');
- echo json_encode(['error' => 'DB init failed', 'detail' => $e->getMessage()], JSON_UNESCAPED_SLASHES);
- exit(1);
- }
- $app = new App();
- $authExternal = new ExternalAuthMiddleware();
- $app->get('/hello', $authExternal, \Controllers\HelloController::class);
- $app->post('/send/mail', $authExternal, \Controllers\MailSendController::class);
- $app->run();
|