PHP code example of phauthentic / error-response

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

    

phauthentic / error-response example snippets


$middleware = new ErrorResponseMiddleware(
    new Psr7ResponseFactory(),
    [
        MyCustomException::class,
        OtherExceptionClass::class
    ]
);

$this->errorResponseFactory->createJsonResponseFromError(
    new ErrorResponse(
        status: 403,
        type: 'https://example.com/probs/out-of-credit',
        title: 'You do not have enough credit.',
        extensions: [
            'balance' => 30,
            'accounts' => [
                "/account/12345",
                "/account/67890"
            ]
        ]
    );
);