PHP code example of esdlabs / reply

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

    

esdlabs / reply example snippets


class LoginController extends Controller {

    public function store()
    {
        try
        {
            ...
        }
        catch (CustomException $e)
        {
            return Reply::error('0x001');
        }
        catch (AnotherException $e)
        {
            return Reply::error('0x002', array('note 1', 'note 2');
        }
        catch (Exception $e)
        {
            return Reply::customError('Custom error description', 500, "Note description");
        }
    }
}

batch
php composer install
batch
php composer update
batch
'Reply' => 'Esdlabs\Reply\Facades\Reply',
batch
php artisan migrate --package=esdlabs/reply
javascript
HTTP/1.1 400 Bad Request

{
    "error_code": "0x001",
    "description"": "Invalid username or password"
}

javascript
HTTP/1.1 406 Not Acceptable

{
    "error_code": "0x002",
    "description"": "Valitation failed",
    "notes" : [
        "note 1", 
        "note 2"
    ]
}