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)
renderResponse
has been removed (replaced byResponseRenderer
)- Legacy "response" middleware support has been removed. Only PSR-15 middleware is supported.
Dispatcher::setAuthProviders()
and::setErrorHandler
have 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.ResponseBuilder
trait 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
@coversDefaultClass
on test cases using those traits, use@covers
.
Traits\EndpointTestCases::getSafeInput()
Traits\EndpointTestCases
now alsouse
sFirehed\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 requiresServerRequestInterface
as 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 nativeEnum
s in PHP 8.1.
- Disallowed using
RequestInterface
inDispatcher
.ServerRequestInterface
is now required - the baseRequestInterface
is 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_LIST
constantInterfaces\EndpointInterface::authenticate()
- this drops legacy authentication support entirely, and will no longer be used even if still defined in implementing classesTraits\Authentication\BearerToken
Traits\DeleteRequest
Traits\GetRequest
Traits\NoOptionalInputs
Traits\NoRequiredInputs
Traits\PostRequest
Traits\PutRequest
Traits\ResponseBuilder
- Widen range of supported Zend Diactoros version
- Added support for
PATCH
HTTP 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\ProviderInterface
Authorization\ProviderInterface
Errors\HandlerInterface
Interfaces\AuthenticatedEndpointInterface
Interfaces\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
BearerToken
authentication 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-type
headers 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
Dispatcher
must now be PSR-11 compliant EndpointTestTrait
renamed toTraits\EndpointTestCases
- Added (and backfilled) this change log
- Added
ResponseBuilder
trait. 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
ErrorHandler
class for request-level fallback (set_error_handler
andset_exception_handler
) - Added basic endpoint skeleton generator:
bin/generate_endpoint [url]
- Added traits for common endpoint behavior:
Request\Get
Request\Post
Request\Put
Request\Delete
Input\NoRequired
Input\NoOptional
Authentication\None
Authentication\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
ResponseBuilder
trait described above, but any PSR-7 library can be used - Improved logging and error handling, with support for
PSR-3
loggers - 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_DEPRECATED
error when used. Their behavior is unchanged.GetRequest
=>Traits\Request\Get
PostRequest
=>Traits\Request\Post
PutRequest
=>Traits\Request\Put
DeleteRequest
=>Traits\Request\Delete
NoRequiredInputs
=>Traits\Input\NoRequired
NoOptionalInputs
=>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/inputobjects
is 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
catch
blocks handleThrowable
whereException
was previously caught