PHP code example of jenky / api-error-bundle

1. Go to this page and download the library: Download jenky/api-error-bundle 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/ */

    

jenky / api-error-bundle example snippets


// config/bundles.php

return [
    // ...
    Jenky\Bundle\ApiError\ApiErrorBundle::class => ['all' => true],
];

// App\ApiError\ErrorFormatterConfigurator.php

use Jenky\ApiError\Formatter\GenericErrorFormatter;

final class ErrorFormatterConfigurator
{
    public function __invoke(GenericErrorFormatter $formatter): void
    {
        $formatter->setFormat([
            'message' => '{title}',
            'status' => '{status_code}',
            'code' => '{code}',
            'errors' => '{errors}',
        ]);
    }
}