runtime/psr-nyholm-laminas

PSR 运行时,包含 nyholm/psr7 和 laminas/laminas-httphandlerrunner

资助包维护!
nyholm

0.1.0 2021-04-29 08:57 UTC

This package is auto-updated.

Last update: 2024-09-12 13:44:27 UTC


README

一个包含 nyholm/psr-7laminas/laminas-httphandlerrunner 的运行时。

如果你是Symfony运行时组件的新手,请阅读主README中的更多信息。

安装

composer require runtime/psr-nyholm-laminas

使用方法

此运行时将自动发现。您可以通过定义环境变量 APP_RUNTIME 来强制您的应用程序使用此运行时。

APP_RUNTIME=Runtime\PsrNyholmLaminas\Runtime

PSR-7

// public/index.php

use Psr\Http\Message\ServerRequestInterface;
use Nyholm\Psr7;

require_once dirname(__DIR__).'/vendor/autoload_runtime.php';

return function (ServerRequestInterface $request) {
    return new Psr7\Response(200, [], 'PSR-7');
};

PSR-15

// public/index.php

use Psr\Http\Server\RequestHandlerInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Message\ResponseInterface;
use Nyholm\Psr7;

require_once dirname(__DIR__).'/vendor/autoload_runtime.php';

class Application implements RequestHandlerInterface {
    // ...
    public function handle(ServerRequestInterface $request): ResponseInterface
    {
        return new Psr7\Response(200, [], 'PSR-15');
    }
}

return function (array $context) {
    return new Application($context['APP_ENV'] ?? 'dev');
};