PHP code example of trihydera / res

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

    

trihydera / res example snippets


use Trihydera\Res\JsonResponse;

// Create an instance of JsonResponse
$response = new JsonResponse();

use Trihydera\Res\XmlResponse;

// Create an instance of XmlResponse
$response = new XmlResponse();

$response->success([
    'value' => 'Its working'
]);

$response->error('Something went wrong', '200');

// Example usage of the useError method
$response->useError('NotFound');

// Example usage of the useError method with your own message
$response->useError('NotFound', 'API resource not found');