Slim API deployment - composer install + full CRUD endpoints
This commit is contained in:
36
api/public/index.php
Normal file
36
api/public/index.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
require __DIR__ . '/../vendor/autoload.php';
|
||||
|
||||
use App\Config\Container;
|
||||
|
||||
// Load .env file safely
|
||||
$envFile = __DIR__ . '/../.env';
|
||||
if (file_exists($envFile)) {
|
||||
$dotenv = new \Symfony\Component\Dotenv\Dotenv();
|
||||
$dotenv->load($envFile);
|
||||
}
|
||||
|
||||
// Boot Eloquent BEFORE creating the app
|
||||
Container::boot();
|
||||
|
||||
$container = Container::build();
|
||||
\Slim\Factory\AppFactory::setContainer($container);
|
||||
|
||||
$app = \Slim\Factory\AppFactory::create();
|
||||
|
||||
// CORS Middleware
|
||||
$app->add(new \Tuupola\Middleware\CorsMiddleware([
|
||||
'origin' => ['https://fahrschultermin.de', 'https://www.fahrschultermin.de'],
|
||||
'methods' => ['GET', 'POST', 'PATCH', 'DELETE', 'OPTIONS'],
|
||||
'headers.allow' => ['Content-Type', 'Authorization', 'X-Requested-With'],
|
||||
'credentials' => true,
|
||||
'cache.maxage' => 86400,
|
||||
]));
|
||||
|
||||
// Routes
|
||||
(require __DIR__ . '/../src/Routes/api.php')($app);
|
||||
|
||||
$app->run();
|
||||
Reference in New Issue
Block a user