All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog and this project adheres to Semantic Versioning.
- PHP 7.4 or later is now required in Composer. This is in line with PHP's own currently supported versions (#33)
- Traits deprecated in 3.0.0 have been removed (renamed equivalents were added in the same release)
renderResponsehas been removed (replaced byResponseRenderer)- Legacy "response" middleware support has been removed. Only PSR-15 middleware is supported.
Dispatcher::setAuthProviders()and::setErrorHandlerhave been removed. You must provide them with a container now, and they will be fetched lazily.Dispatcher::setRequest(ServerRequestInterface)has been removed, and the request is now provided directly to::dispatch(ServerRequestInterface)HandlesOwnErrorsTestCases::getEndpoint()has been renamed toHandlesOwnErrorsTestCases::getErrorHandlingEndpoint(). This prevents an incompatibility in PHP8 from abstract trait method validation colliding with LSP enforcement.ResponseBuildertrait has been removed. Instead, opt to use a PSR-7 implementation of your choosing.- Coverage annotations in exported tests traits have been adjusted.
Instead of using
@coversDefaultClasson test cases using those traits, use@covers.
Traits\EndpointTestCases::getSafeInput()Traits\EndpointTestCasesnow alsousesFirehed\Input\SafeInputTestTrait. This adds::getSafeInputFromData()but will result in an import conflict for test cases that have already opted to use the same trait- Console command:
vendor/bin/api compile:all - Console command:
vendor/bin/api generate:config - Console command:
vendor/bin/api generate:endpoint - Console command:
vendor/bin/api generate:frontController - Greatly improved support for use in long-running processes, like ReactPHP
- Expanded support for psr/container to allow both 1.x and 2.x
- Files generated during compilation are now expected to be excluded from version control and generated during automated build processes (#84)
- Framework-generated files are now auto-detected thanks to the above compile requirement (#84)
Dispatcher::setEndpointList()andDispatcher::setParserList()are now internal use only, and are no longer called in the generated front controller (#84)Dispatcher::dispatch()now requiresServerRequestInterfaceas a parameter. This replacessetRequest(#101)- The body parser list (based on MIME-types) is now explicitly hardcoded. Previously this was tied to a scanned vendor directory, so in practice nothing has changed. This may become configurable in the future.
- Dispatcher::ENDPOINT_LIST has been marked internal
- Direct use of the HTTPMethod class is considered deprecated.
Endpoints are highly encouraged to use the corresponding traits (
Traits\Request\...) instead. This will greatly ease the transition to nativeEnums in PHP 8.1.
- Disallowed using
RequestInterfaceinDispatcher.ServerRequestInterfaceis now required - the baseRequestInterfaceis no longer supported. renderResponse()functionDispatcher::addResponseMiddleware()(use addMiddleware with PSR-15 MW)Dispatcher::setAuthProviders()(use setContainer)Dispatcher::setErrorHandler()(use setContainer)Dispatcher::setRequest()(provide the request directly to::dispatch())Dispatcher::PARSER_LISTconstantInterfaces\EndpointInterface::authenticate()- this drops legacy authentication support entirely, and will no longer be used even if still defined in implementing classesTraits\Authentication\BearerTokenTraits\DeleteRequestTraits\GetRequestTraits\NoOptionalInputsTraits\NoRequiredInputsTraits\PostRequestTraits\PutRequestTraits\ResponseBuilder
- Widen range of supported Zend Diactoros version
- Added support for
PATCHHTTP method
Traits\Request\Patch
- Overhauled authentication (#43)
- Overhauled error handling (#37, #38, #63)
- Added support for PSR-15 Middleware (#59)
- Added additional documentation in the README (#66)
Authentication\ProviderInterfaceAuthorization\ProviderInterfaceErrors\HandlerInterfaceInterfaces\AuthenticatedEndpointInterfaceInterfaces\HandlesOwnErrorsInterface
- Internal refactoring
- If a RequestInterface object is provided to the dispatcher, it will be internally converted to a ServerRequestInterface to ensure compatibility with Middleware and error handling. Relying on this functionality is deprecated from the start, highly discouraged, and may be imperfect.
- Deprecated
ErrorHandler(#37) - Deprecated use of base RequestInterface (#48)
- Deprecated the
BearerTokenauthentication trait (#73)
- Fixed incorrect return type
- Removes the use of
fguillot/simplelogger, since it has been abandoned. This is not treated as a breaking change since it's not safe to implicitly rely on a dependency's dependencies.
- OPTIONS requests are now supported
- Fixed issue where
Content-typeheaders with directives (e.g.Content-type: application/json; charset=utf-8) are processed correctly
- Added URI matching tests into
EndpointTestCases. Updating to this version will result in existing passing tests using said trait being skipped until good and bad URI matches are added into the test case.
- Fixed minor issue where variables with certain names defined in the included configuration container's file could impact the code generation scripts
- Fixed issue in generated front controller where config file would be loaded twice
- Containers injected into the
Dispatchermust now be PSR-11 compliant EndpointTestTraitrenamed toTraits\EndpointTestCases
- Added (and backfilled) this change log
- Added
ResponseBuildertrait. It addsemptyResponse(),htmlResponse(),jsonResponse(), andtextResponse()methods to build a PSR-7-compliant response with the provided data and optional HTTP status code. Internally uses the Zend Diactoros library - Added
ErrorHandlerclass for request-level fallback (set_error_handlerandset_exception_handler) - Added basic endpoint skeleton generator:
bin/generate_endpoint [url] - Added traits for common endpoint behavior:
Request\GetRequest\PostRequest\PutRequest\DeleteInput\NoRequiredInput\NoOptionalAuthentication\NoneAuthentication\BearerToken
- Code is now tested automatically with Travis CI. PHP 7.0, 7.1, and 7.2 are supported
- Zend-Diactoros is now included as a dependency. It is only used by the
ResponseBuildertrait described above, but any PSR-7 library can be used - Improved logging and error handling, with support for
PSR-3loggers - Improved validation of
.apiconfig, displaying more useful errors to the user - [Breaking] The container that's optionally injected into the Dispatcher is now expected to be PSR-11 compliant
- [Breaking] EndpointTestTrait moved to
Traits\EndpointTestCases
- Reorganized endpoint traits; old versions still work but will now emit a
E_USER_DEPRECATEDerror when used. Their behavior is unchanged.GetRequest=>Traits\Request\GetPostRequest=>Traits\Request\PostPutRequest=>Traits\Request\PutDeleteRequest=>Traits\Request\DeleteNoRequiredInputs=>Traits\Input\NoRequiredNoOptionalInputs=>Traits\Input\NoOptional
- Additional code quality tools have been added
- Reworked the auto-generated front controller
- Added
Firehed\API\renderResponse()which takes a complete PSR-7 response message and outputs the headers and body
- Fixed issue where exceptions thrown during error handling would result in unexpected behavior
- Fixed lingering dependency on InputObjects that slipped through
firehed/inputobjectsis now an optional, suggested package, and is no longer directly required. Projects using it must add it to their own Composer required section
- Added traits for indicating an endpoint's HTTP method
- Added trait for indicating an endpoint has no required inputs
- Added trait for indicating an endpoint has no optional inputs
- Updates to some dependencies
Dispatcher->addResponseMiddleware(): Allows providing post-execution handlers (for adding headers, etc)
- Updates to some dependencies
- Dispatcher explicitly casts PSR-7 request body to string before
Released for PHP 7
declare(strict_types=1)- return types
- Improved internal documentation
- Updated PHPUnit version
- Updated PHP requirement in composer.json
- Updated input dependencies
- Most
catchblocks handleThrowablewhereExceptionwas previously caught