PHP code example of cherry-project / response

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

    

cherry-project / response example snippets




use Cherry\HttpUtils\Response;

$response = new Response();

$arr = [
    'test' => 'vTest',
    'test2' => [
        'test2.1' => '2.1',
        'test2.2' => [
            'test2.2.1' => '2.2.1'
        ]
    ]
];

echo $response->sendResponse(json_encode($arr), 200, ['Content-Type' => 'application/json']);