PHP code example of mojtabarks / api-response

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

    

mojtabarks / api-response example snippets

`

$successResponse = $this->successResponse
    // ->setCode(xxxx)
    // ->setMessage("blah blah blah blah !")
    // ->setSuccessResponse(--boolean !!!--)
    // ->setResponseKey('data')
    // ->setResponseValue(--array-- => [  // --------------> SET DATA METHOD IS ONLY AVAILABLE FOR SUCCESS RESPONSE
        'projectName' => 'my awesome project',
        .
        .
        .
    ])
    ->render();



$errorResponse = $this->errorResponse
    // ->setCode(xxxx)
    // ->setMessage("blah blah blah blah !")
    // ->setSuccessResponse(--boolean !!!--)
    // ->setResponseKey('error')
    // ->setResponseValue(--array-- => [ // --------------> SET ERROR METHOD IS ONLY AVAILABLE FOR ERROR RESPONSE
        'error text' => 'looks like something went wrong',
        .
        .
        .
    ])
    ->render();



$customResponse = $this->customResponse
    // ->setCode(XXXXX)
    // ->setMessage('BLAH BLAH BLAH !')
    // ->setSuccessStatus(BOOLEAN)
    // ->setResponseKey('additional')
    // ->setResponseValue([
    //    'custom text' => 'custom message here',
        .
        .
        .
    //])
    ->render();