Add doctrine and seperate out the renderer
This commit is contained in:
@ -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
13
app/Entity/Book.php
Normal 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
10
app/bin.php
Normal 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();
|
||||
|
@ -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',
|
||||
],
|
||||
]);
|
Reference in New Issue
Block a user