test
Some checks failed
/ ls (push) Failing after 11s

This commit is contained in:
lubiana 2023-11-27 21:44:24 +01:00
parent 45b5b746f6
commit 2872d932b6
6 changed files with 38 additions and 8 deletions

View file

@ -3,7 +3,7 @@ jobs:
ls: ls:
runs-on: docker runs-on: docker
container: container:
image: git.php.fail/lubiana/container/php:8.2.11-node-2 image: git.php.fail/lubiana/container/php:8.3.0-node
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- name: Get Composer Cache Directory - name: Get Composer Cache Directory

View file

@ -15,7 +15,7 @@
} }
], ],
"require": { "require": {
"php": ">=8.2", "php": ">=8.3",
"ext-apcu": "*", "ext-apcu": "*",
"php-di/php-di": "^7.0.1", "php-di/php-di": "^7.0.1",
"nikic/fast-route": "^1.3", "nikic/fast-route": "^1.3",

View file

@ -4,7 +4,7 @@ use PhpStyler\Files;
use PhpStyler\Styler; use PhpStyler\Styler;
return new Config( return new Config(
files: new Files(__DIR__ . '/src'),
styler: new Styler(), styler: new Styler(),
files: new Files(__DIR__ . '/src'),
cache: __DIR__ . '/.php-styler.cache', cache: __DIR__ . '/.php-styler.cache',
); );

View file

@ -6,6 +6,7 @@ use DI\ContainerBuilder;
use Lubian\AttributeMagic\Infrastructure\Event\Dispatcher; use Lubian\AttributeMagic\Infrastructure\Event\Dispatcher;
use Lubian\AttributeMagic\Infrastructure\Event\DispatcherFactory; use Lubian\AttributeMagic\Infrastructure\Event\DispatcherFactory;
use Lubian\AttributeMagic\Infrastructure\Finder; use Lubian\AttributeMagic\Infrastructure\Finder;
use Lubian\AttributeMagic\Infrastructure\HttpKernel;
use Lubian\AttributeMagic\Infrastructure\WebApp\Request\RequestEvent; use Lubian\AttributeMagic\Infrastructure\WebApp\Request\RequestEvent;
use Lubian\AttributeMagic\Infrastructure\WebApp\Route\HandlerResolver; use Lubian\AttributeMagic\Infrastructure\WebApp\Route\HandlerResolver;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
@ -23,9 +24,11 @@ $container = (new ContainerBuilder)->addDefinitions(
=> new HandlerResolver($d, $cached), => new HandlerResolver($d, $cached),
], ],
)->build(); )->build();
$dispatcher = $container->get(Dispatcher::class); $kernel = $container->get(HttpKernel::class);
assert($dispatcher instanceof Dispatcher); assert($kernel instanceof HttpKernel);
$request = new RequestEvent(Request::createFromGlobals());
$dispatcher->dispatch($request); $response = $kernel->handle(Request::createFromGlobals());
$request->response?->send();
$response->send();
exit(); exit();

View file

@ -9,6 +9,11 @@ use Symfony\Component\HttpFoundation\Response;
final class HalloDimi final class HalloDimi
{ {
/**
* Returns a JSON response with the message "Hallo Dimi".
*
* @return Response The JSON response.
*/
#[AsHandler(HttpMethod::GET, '/dimi')] #[AsHandler(HttpMethod::GET, '/dimi')]
public function hallo(): Response public function hallo(): Response
{ {

View file

@ -0,0 +1,22 @@
<?php
namespace Lubian\AttributeMagic\Infrastructure;
use Lubian\AttributeMagic\Infrastructure\Event\Dispatcher;
use Lubian\AttributeMagic\Infrastructure\WebApp\Request\RequestEvent;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
class HttpKernel
{
public function __construct(
private readonly Dispatcher $dispatcher,
){}
public function handle(Request $request): Response
{
$requestEvent = new RequestEvent($request);
$this->dispatcher->dispatch($requestEvent);
return $requestEvent->response ?? throw new \Exception('errror');
}
}