PHP code example of antare74 / response-formatter

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

    

antare74 / response-formatter example snippets




use Illuminate\Support\Facades\Route;
use Antare74\ResponseFormatter\Format;

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::get('/success', function () {
    return Format::success([
        'name' => 'Antare74',
        'age' => '74',
        'address' => 'Jakarta',
    ], 'Success Message');
});

Route::get('/error', function () {
    return Format::error([
        'my_error_data' => 'Error Message',
    ], 'Error Message', 500);
});