PHP code example of rhumsaa / vnderror

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

    

rhumsaa / vnderror example snippets


use Ramsey\VndError\VndError;

$vndError = new VndError('Validation failed', 42);
$vndError->addLink('help', 'http://.../', array('title' => 'Error Information'));
$vndError->addLink('describes', 'http://.../', array('title' => 'Error Description'));

header('Content-Type: application/vnd.error+json');
echo $vndError->asJson();

header('Content-Type: application/vnd.error+xml');
echo $vndError->asXml();
bash
php composer.phar