PHP code example of laratoolbox / responder

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

    

laratoolbox / responder example snippets


return responder()
        ->addHeader('X-Secret1', 'secret1')
        ->addHeader('X-Secret2', 'secret2')
        ->addHeader('X-Secret3', 'secret3')
        ->setData(\App\Models\User::select('id', 'name')->find(1))
        ->addExtraData('custom-key', 'custom-value')
        ->send();

throw new \LaraToolbox\Responder\Exceptions\ResponderException(
    \LaraToolbox\Responder\ResponseCodes::ERROR,
    $customData = [1,2,3]
);