This commit is contained in:
4
webseite-react-php/slim-php/public/.htaccess
Normal file
4
webseite-react-php/slim-php/public/.htaccess
Normal file
@@ -0,0 +1,4 @@
|
||||
RewriteEngine On
|
||||
RewriteCond %{REQUEST_FILENAME} !-f
|
||||
RewriteCond %{REQUEST_FILENAME} !-d
|
||||
RewriteRule ^ index.php [QSA,L]
|
||||
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();
|
||||
11
webseite-react-php/slim-php/public/router.php
Normal file
11
webseite-react-php/slim-php/public/router.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
$uri = urldecode(parse_url($_SERVER['REQUEST_URI'] ?? '/', PHP_URL_PATH) ?: '/');
|
||||
|
||||
if ($uri !== '/' && file_exists(__DIR__ . $uri)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
require __DIR__ . '/index.php';
|
||||
Reference in New Issue
Block a user