PHP code example of controlabs / http-exceptions

1. Go to this page and download the library: Download controlabs/http-exceptions 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/ */

    

controlabs / http-exceptions example snippets


use Controlabs\Http\Exception\BadRequest;

throw new BadRequest();

throw new BadRequest("I'm gonna make him an offer he can't refuse.");

try {
} catch (BadRequest $e) {
    $e->response()->toArray();
    // or
    $e->response()->toJson();
}