PHP code example of sharadkashyap / php-api-response-toolkit

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

    

sharadkashyap / php-api-response-toolkit example snippets




use SharadKashyap\ApiResponse\Response\SuccessResponse;

$response = new SuccessResponse(
    'User created successfully',
    [
        'id' => 1,
        'name' => 'John'
    ]
);

echo $response->toJson();



use SharadKashyap\ApiResponse\Response\ErrorResponse;

$response = new ErrorResponse(
    'User not found',
    404
);

echo $response->toJson();
bash
git clone https://github.com/sharadkashyap/php-api-response-toolkit.git
bash
vendor/bin/php-cs-fixer fix --dry-run