Changelog
v2.0.0
Breaking Changes:
- MiddlewareQueue
is no longer a singleton, so every
QueueRequestHandler
now gets its own queue of middlewares. Previously all handlers shared one
queue and middlewares passed to any but the first handler were silently ignored. Use
new MiddlewareQueue()instead ofMiddlewareQueue::getInstance(). - QueueRequestHandler::handle()
now works on a copy of the middleware queue for each request,
so one handler can process any number of requests (e.g. in long-running servers like RoadRunner, Swoole or
FrankenPHP). Previously every call after the first returned the stale response of the first run without invoking any
middleware. While a request is being handled,
QueueRequestHandler::queuereturns that request's copy, so changes made by middlewares only apply to the current request. - QueueRequestHandler
no longer catches exceptions thrown by a middleware. As intended by
PSR-15, they are now passed through all previous middlewares, so these can handle them as needed, and finally to the
caller of
handle(). Add the new ErrorMiddleware as the first middleware to convert them into responses. Error responses no longer reveal any details to the client and theWarningheader was removed (see below). - AbstractMiddleware
now works with any request handler implementing
PsrHttpServerRequestHandlerInterfaceinstead of throwing aDomainExceptionfor anything but a QueueRequestHandler . Therefore the type of the protected propertyAbstractMiddleware::requestHandlerchanged toRequestHandlerInterface. Middlewares accessing properties ofQueueRequestHandler(e.g.$this->requestHandler->request) still work with it, but static analyzers will report them unless you check the type withinstanceof QueueRequestHandlerfirst. guzzlehttp/psr7is no longer a required dependency. The package now works with any PSR-7 and PSR-17 implementation. Guzzle is still used by default if it's installed, so add it to your own dependencies if you rely on it (composer require guzzlehttp/psr7). Otherwise, pass the server request and a response factory to the constructors of QueueRequestHandler and ErrorMiddleware .
Minor Changes:
- Added ErrorMiddleware
to convert any exception or error (i.e. every
Throwable) into an HTTP error response. By default, the response only states the HTTP status and the details are written to PHP's error log. The exception code is used as status if it's a valid HTTP error status (400to599), otherwise it's500. A custom error handler can be passed to the constructor. - Added optional server request and PSR-17 response factory as second and third argument to the constructor of QueueRequestHandler , and an optional response factory as second argument to the constructor of ErrorMiddleware .
Bugfixes:
- QueueRequestHandler::respond()
now sends every header value as a separate header line.
Previously multiple values were combined into one comma-separated line, which broke responses setting more than one
cookie. Headers already set by PHP (e.g.
Cache-Controlfromsession_start()) are now replaced instead of being sent twice, except for cookies. - QueueRequestHandler::respond()
now sends the status line after all other headers. Previously
PHP silently changed the status code to
302when aLocationheader was present (unless the status was201or3xx), and to401when aWWW-Authenticateheader was present, e.g. turning a202 Acceptedinto a redirect.
Maintenance:
- Added a test suite for PHPUnit (run with
composer phpunit:test), which is run for every supported PHP version (8.1 to 8.5) on GitHub - Excluded the documentation, tests and configuration files of development tools from the Composer package, so it only
contains the source code,
composer.json,LICENSEandREADME.md - The documentation is no longer part of the repository, but built and deployed to
GitHub Pages automatically for every release. To read it
offline, build it locally with
composer phpdoc:build - All code checks on GitHub now run the tool versions installed by Composer on PHP 8.5, just like when running them locally, instead of using different third-party actions and Docker images
- Updated Psalm to version 7 (still version 6 on PHP 8.1, which isn't supported by Psalm 7)
v1.3.1
Maintenance:
- Moved exception handling from QueueRequestHandler::handle() to separate method for better readability
- Updated links to documentation
v1.3.0
Minor Changes:
- Added check in AbstractMiddleware::process() to ensure correct request handler type
Maintenance:
- Raised PHPStan rule level to 10
v1.2.1
Maintenance:
- Updated dependencies
- Added annotations, removed redundant type hints, and made classes final where appropriate
v1.2.0
Minor Changes:
- Added a
Warningheader to identify response messages from converted exceptions - Removed the option to provide an exit status to QueueRequestHandler::respond()
- Added Composer command for development tools (PHP Mess Detector, Psalm Taint Analysis)
Maintencance:
- Updated dependencies
v1.1.0
New Features:
- Extended documentation
Minor Changes:
- Added Composer commands for development tools (PHP_CodeSniffer, PHP-CS-Fixer, PHPStan, Psalm and phpDocumentor)
Maintencance:
- Updated dependencies
v1.0.1
Maintenance:
- Updated dependencies
v1.0.0
Initial Release