PHP code example of turksoy / responsebuilder

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

    

turksoy / responsebuilder example snippets

 php
    $user = [
        'id'    => 1,
        'name'  => 'hakan',
        'email' => '[email protected]'
    ];
    
    $token = 'sakljSDAIASDKJERNMWE';

    return reponseBuilder()
        ->result('user',$user)
        ->result('token',$token)
        ->ok();

 json
{
    "meta": {
        "messages": {
            "success": [],
            "warning": [],
            "error": [
                "User not found!"
            ],
            "validation_error": []
        }
    },
    "payload": null
}