Download the PHP package loadsys/cakephp-serializers-errors without Composer
On this page you can find all versions of the php package loadsys/cakephp-serializers-errors. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download loadsys/cakephp-serializers-errors
More information about loadsys/cakephp-serializers-errors
Files in loadsys/cakephp-serializers-errors
Package cakephp-serializers-errors
Short Description Used to serialize CakePHP Errors and Exceptions, primarily as HTML, JSON or JSON API.
License MIT
Homepage https://github.com/loadsys/CakePHP-Serializers-Errors
Informations about the package cakephp-serializers-errors
CakePHP SerializersErrors
Used to serialize CakePHP Errors and Exceptions, primarily as HTML, JSON or JSON API.
Adds two new Exception Classes to extend from to get JSON API formatted error messages.
Requirements
- CakePHP 2.3+
- PHP 5.4+
Installation
Composer
`
Usage
- Add this plugin to your application by adding this line to your bootstrap.php
``
-
Update your
core.php
to use the plugin's ExceptionRenderer in place of the core's - Once this is done Exceptions are rendered as possible, JSON API errors,
JSON formated errors or standard HTML responses, differing on the request
Accepts
Header. - So if you use:
Accepts: application/vnd.api+json
JSON API Errors are returnedAccepts: application/json
JSON Errors are returnedAccepts: */*
Normal CakePHP HTML Style Errors are returned
- If you build custom Exceptions that extend
BaseSerializerException
you get Exceptions that enable the full feature set of JSON API errors in addition to be rendering in the pattern described above.
Sample Responses
Here are some sample response for the different Exception classes.
BaseSerializerException
Accepts: application/vnd.api+json
Matches the format expected in JSON API
Accepts: application/json
ValidationBaseSerializerException
Accepts: application/vnd.api+json
Matches the format expected in JSON API
Accepts: application/json
Matches the format expected in Ember.js DS.Errors Class
Contributing
Reporting Issues
Please use GitHub Isuses for listing any known defects or issues.
Development
When developing this plugin, please fork and issue a PR for any new development.
The Complete Test Suite for the plugin can be run via this command:
./lib/Cake/Console/cake test SerializersErrors AllSerializersErrors