PHP code example of ramsey / vnderror

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

    

ramsey / 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