alexpts / next2
Micro application for PSR-7
dev-master
2023-02-05 18:30 UTC
Requires
- php: ~8.1
- alexpts/mutable-psr7: ^0.2.1
- psr/http-message: ^1.0
- psr/http-server-middleware: ^1.0
Requires (Dev)
- phpunit/phpunit: ^10.0
This package is auto-updated.
Last update: 2024-11-05 22:17:28 UTC
README
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