alexpts/next2

Micro application for PSR-7

dev-master 2023-02-05 18:30 UTC

This package is auto-updated.

Last update: 2024-11-05 22:17:28 UTC


README

phpunit codecov

High performance mico framework

Install

composer require alexpts/next2

Docs

http://alexpts.github.io/php-next2-docs/

Hello World

<?php

use PTS\Next2\Context\ContextInterface;
use PTS\Next2\MicroApp;
use PTS\Psr7\Response\JsonResponse;
use PTS\Psr7\ServerRequest;
use PTS\Psr7\Uri;

require_once './vendor/autoload.php';

$psr7Request = new ServerRequest('GET', new Uri('/'));

$app = new MicroApp;

$app->store->get('/', function(ContextInterface $ctx) {
    $response = new JsonResponse(['message' => 'Hello World!']);
    $ctx->setResponse($response);
});

$psr7Response = $app->handle($psr7Request); // psr-15 runner