Add doctrine and seperate out the renderer

This commit is contained in:
Tim
2023-08-16 14:28:06 +02:00
parent 56e8caa26c
commit 59200be680
11 changed files with 2158 additions and 54 deletions

View File

@ -2,6 +2,7 @@
namespace App\Controller;
use App\Entity\Book;
use App\View\RouteView;
use Ardent\Undercurrent\Attribute\Route;
use Ardent\Undercurrent\Http\GenericResponse;
@ -10,6 +11,7 @@ use Ardent\Undercurrent\Http\RouterConfig;
use Ardent\Undercurrent\Http\StatusEnum;
use Ardent\Undercurrent\View\BaseView;
use Ardent\Undercurrent\View\ViewInterface;
use Doctrine\ORM\EntityManager;
class HelloWorldController
{
@ -48,4 +50,13 @@ class HelloWorldController
{
return new GenericResponse("Hello $name!");
}
#[Route('/db')]
public function db(EntityManager $em): ResponseInterface
{
$repo = $em->getRepository(Book::class);
dump($repo->findAll());
return new GenericResponse("DB stuff");
}
}

13
app/Entity/Book.php Normal file
View File

@ -0,0 +1,13 @@
<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity]
#[ORM\Table(name: 'book')]
class Book
{
#[ORM\Id, ORM\Column, ORM\GeneratedValue]
private int $id;
}

10
app/bin.php Normal file
View File

@ -0,0 +1,10 @@
<?php
use App\Kernel;
use Ardent\Undercurrent\Config\AppConfig;
require_once dirname(__DIR__) . '/vendor/autoload.php';
$kernel = new Kernel(new AppConfig(__DIR__ . '/../app'));
$container = $kernel->setup();

View File

@ -5,5 +5,12 @@ namespace App;
use Ardent\Undercurrent\Config\GenericConfig;
return new GenericConfig([
'key' => 'value',
'dev' => true,
'orm' => [
'driver' => 'pdo_mysql',
'host' => 'localhost',
'user' => 'root',
'password' => 'password',
'db' => 'db',
],
]);