PHP code example of loadsys / cakephp-serializers-errors

1. Go to this page and download the library: Download loadsys/cakephp-serializers-errors library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

loadsys / cakephp-serializers-errors example snippets


CakePlugin::load('SerializersErrors', array('bootstrap' => true));

Configure::write('Exception', array(
	'handler' => 'ErrorHandler::handleException',
	'renderer' => 'SerializersErrors.SerializerExceptionRenderer',
	'log' => true,
));

throw new BaseSerializerException("This is a message.", "Something failed", 400, "Custom ID For Error", "http://docs.domain.com/api/v1/custom-id-for-error", array(), array())

throw new BaseSerializerException("This is a message.", "Something failed", 400, "Custom ID For Error", "http://docs.domain.com/api/v1/custom-id-for-error", array(), array())

throw new ValidationBaseSerializerException("This is a message.", $this->ModelName->invalidFields(), 422, "Custom ID For Error", "http://docs.domain.com/api/v1/custom-id-for-error", array(), array())

$invalidFields = $this->ModelName->invalidFields();
throw new ValidationBaseSerializerException("This is a message.", $invalidFields, 422, "Custom ID For Error", "http://docs.domain.com/api/v1/custom-id-for-error", array(), array())