This commit is contained in:
33
webseite-react-php/slim-php/public/index.php
Normal file
33
webseite-react-php/slim-php/public/index.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use App\Config;
|
||||
use App\Middleware\CorsMiddleware;
|
||||
use App\Repository\ProductRepository;
|
||||
use DI\Container;
|
||||
use Slim\Factory\AppFactory;
|
||||
|
||||
require __DIR__ . '/../vendor/autoload.php';
|
||||
|
||||
$dotenv = Dotenv\Dotenv::createImmutable(dirname(__DIR__));
|
||||
$dotenv->safeLoad();
|
||||
|
||||
$container = new Container();
|
||||
$container->set(PDO::class, static fn () => Config::pdo());
|
||||
$container->set(
|
||||
ProductRepository::class,
|
||||
static fn ($c) => new ProductRepository($c->get(PDO::class))
|
||||
);
|
||||
|
||||
AppFactory::setContainer($container);
|
||||
$app = AppFactory::create();
|
||||
|
||||
$app->addBodyParsingMiddleware();
|
||||
$app->addRoutingMiddleware();
|
||||
$app->addErrorMiddleware(true, true, true);
|
||||
$app->add(new CorsMiddleware());
|
||||
|
||||
(require __DIR__ . '/../src/Routes/productRoutes.php')($app);
|
||||
|
||||
$app->run();
|
||||
Reference in New Issue
Block a user