add session, container, and routes to app
This commit is contained in:
parent
aa89f77fcb
commit
175bd3734b
1 changed files with 19 additions and 3 deletions
|
|
@ -1,22 +1,38 @@
|
|||
<?php
|
||||
session_start([
|
||||
'cookie_httponly' => true,
|
||||
'cookie_secure' => !empty($_SERVER['HTTPS']),
|
||||
'cookie_samesite' => 'Lax',
|
||||
]);
|
||||
|
||||
require __DIR__ . '/../vendor/autoload.php';
|
||||
|
||||
use DI\Container;
|
||||
use DigiWill\Controllers\UserController;
|
||||
use Slim\Factory\AppFactory;
|
||||
use Slim\Views\Twig;
|
||||
use Slim\Views\TwigMiddleware;
|
||||
use Tests\Fakes\FakeUserRepository;
|
||||
use DigiWill\Repositories\UserRepository;
|
||||
use DigiWill\MiddleWare\AuthMiddleware;
|
||||
|
||||
require __DIR__ . '/../vendor/autoload.php';
|
||||
|
||||
$container = new Container();
|
||||
$container = new Container([
|
||||
UserRepository::class => DI\create(FakeUserRepository::class),
|
||||
]);
|
||||
|
||||
$app = AppFactory::createFromContainer($container);
|
||||
|
||||
$twig = Twig::create(__DIR__ . '/../templates', ['cache' => false]);
|
||||
|
||||
$auth = new AuthMiddleware();
|
||||
|
||||
$app->add(TwigMiddleware::create($app, $twig));
|
||||
$app->addErrorMiddleware(true, false, false);
|
||||
|
||||
$app->get('/', [UserController::class, 'home']);
|
||||
$app->get('/login', [UserController::class, 'login']);
|
||||
$app->get('/logout', [UserController::class, 'logout']);
|
||||
$app->post('/login', [UserController::class, 'doLogin']);
|
||||
$app->get('/dashboard', [UserController::class, 'dashboard'])->add($auth);
|
||||
|
||||
$app->run();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue