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:
runs-on: docker
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:
- uses: actions/checkout@v3
- name: Get Composer Cache Directory

View file

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

View file

@ -4,7 +4,7 @@ use PhpStyler\Files;
use PhpStyler\Styler;
return new Config(
files: new Files(__DIR__ . '/src'),
styler: new Styler(),
files: new Files(__DIR__ . '/src'),
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\DispatcherFactory;
use Lubian\AttributeMagic\Infrastructure\Finder;
use Lubian\AttributeMagic\Infrastructure\HttpKernel;
use Lubian\AttributeMagic\Infrastructure\WebApp\Request\RequestEvent;
use Lubian\AttributeMagic\Infrastructure\WebApp\Route\HandlerResolver;
use Symfony\Component\HttpFoundation\Request;
@ -23,9 +24,11 @@ $container = (new ContainerBuilder)->addDefinitions(
=> new HandlerResolver($d, $cached),
],
)->build();
$dispatcher = $container->get(Dispatcher::class);
assert($dispatcher instanceof Dispatcher);
$request = new RequestEvent(Request::createFromGlobals());
$dispatcher->dispatch($request);
$request->response?->send();
$kernel = $container->get(HttpKernel::class);
assert($kernel instanceof HttpKernel);
$response = $kernel->handle(Request::createFromGlobals());
$response->send();
exit();

View file

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