init: React frontend + PHP/Slim backend chat app

This commit is contained in:
2026-05-14 10:46:20 +08:00
commit 893cd136c1
92 changed files with 20834 additions and 0 deletions
+35
View File
@@ -0,0 +1,35 @@
<?php
require __DIR__ . '/../vendor/autoload.php';
use Slim\Factory\AppFactory;
require __DIR__ . '/../src/config.php';
require __DIR__ . '/../src/db.php';
require __DIR__ . '/../src/jwt.php';
$app = AppFactory::create();
// CORS for dev
$app->add(function ($request, $handler) {
$response = $handler->handle($request);
return $response
->withHeader('Access-Control-Allow-Origin', '*')
->withHeader('Access-Control-Allow-Headers', 'X-Requested-With, Content-Type, Accept, Origin, Authorization')
->withHeader('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, PATCH, OPTIONS');
});
$app->addRoutingMiddleware();
$app->addErrorMiddleware(true, true, true);
// Options handler
$app->options('/{routes:.+}', function ($request, $response) {
return $response;
});
// Init DB
getDb();
// Register routes
require __DIR__ . '/../src/routes.php';
$app->run();