Cakephp default error response but i need to json format error response

As mentioned in the docs CakePHP ships with error renderers for both web and console environments. If however, you would like to replace the logic that renders errors you can create a custom error renderer class which then outputs json.

But you can also try something like GitHub - mixerapi/mixerapi: CakePHP API Plugin for REST + JSON API Development [READ-ONLY] which has

  • Error Handling: Handles exception rendering in XML or JSON.

as you can see in the readme

But if you only need the exception rendering part you can also just use GitHub - mixerapi/exception-render: Handles rendering entity validation errors and other exceptions for your API [READ-ONLY]