[BREAKING]
This is backward incompatible change in signature ofResponseBuilder::buildResponse()
, but it only affects you if you extendResponseBuilder
and provide own implementation to manipulate response object (see Manipulating Response Object). If you do not, then you are not affected.
[Very Low]
Data conversion logic changed slightly. Now it checks if we have configuration entry matching exactly the object's class name. If not, then we'd try to find if we have any configuration for its parent class. See Data Conversion for details.
[Very Low]
Removed ability to define own names for response keys which reduces code complexity and simplifies the library. From now one you need to stick to default names now (success
,code
,message
,locale
,data
).
- Requires Laravel 6.0+ and PHP 7.2+
[BREAKING]
In previous versions built-in reserved codes were hardcoded and always in range of 1-63 which, in general contradicted the whole idea of having code ranges. Starting from v6, all your API codes are always within user assigned code range including built-in codes. This implies some breaking changes to the configuration ofResponseBuilder
and some changes in the way built-in codes are handled. Because all built-in codes are now remapped to user defined code range, all built-in code constants likeOK
orEX_HTTP_SERVICE_UNAVAILABLE
, previously defined inBaseApiCodes
class are gone. If you for any reason need to get the value of built in code, use what's the value You can still have If you need to get the value of built-in code you need to use replacement methods. These are named the same way as the constants, so if you want to get code ofApiCodes::OK
you need to callApiCodes::OK()
(or directly,BaseApiCodes::OK()
). SeeBaseApiCodes
class for all available public functions. Additionally, first 20 codes (0 to 19 inclusive) of your code range is reserved for built-in codes, which means that if you define your code range to be100
-199
then you cannot use codes100
to119
for own purposes. The first code you can assign to own API code is120
.[Low]
Removedexception_handler.use_exception_message_first
feature.[Low]
RemovedResponseBuilder::DEFAULT_API_CODE_OK
constant.[Low]
RemovedgetReservedMinCode()
,getReservedMinCode()
,getReservedMessageKey()
methods fromApiCodesHelpers
trait.[Low]
AllResponseBuilder
internal code constants are removed. If you need to get the valid API code for internal codes, useBaseApiCodes
class' methods:OK()
,NO_ERROR_MESSAGE()
,EX_HTTP_NOT_FOUND()
,EX_HTTP_SERVICE_UNAVAILABLE()
,EX_HTTP_EXCEPTION()
,EX_UNCAUGHT_EXCEPTION()
,EX_AUTHENTICATION_EXCEPTION()
andEX_VALIDATION_EXCEPTION()
that would return valid API code in currently configured range.[Low]
Removedresponse_key_map
configuration option.
- No public release.
ApiCodeBase
class is nowBaseApiCodes
- ExceptionHandler's debug trace no longer depends on
APP_DEBUG
value and can be enabled independently
success()
now accepts (optional)api_code
too, therefore signature of this method as well as and argument order changed. This makes it partially incompatible with what have been in v2, however in majority of uses this change should pose no threat at all. If you were just callingsuccess()
orsuccess($data)
(which is 99,9% of use cases) then you are all fine and no change is needed. But if you were setting ownhttp_code
orlang_args
when callingsuccess()
then you need to update your code.:api_code
is now the code value placeholder in all the strings.:error_code
is no longer supportedErrorCodes
class is nowApiCodeBase
- ApiCodeBase's
getErrorCodeConstants()
is nowgetApiCodeConstants()
- ApiCodeBase's
getMapping()
is nowgetCodeMessageKey()
- ApiCodeBase's
getBaseMapping()
is nowgetReservedCodeMessageKey()
- Internal constants for
ExceptionHandlerHelper
supported exceptions are now prefixed withEX_
(i.e.HTTP_NOT_FOUND
is nowEX_HTTP_NOT_FOUND
)
- First public release
- Initial (internal) release