PHP code example of yaroslawww / laravel-api-response

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

    

yaroslawww / laravel-api-response example snippets


Route::get('/', function () {
    return ApiResponse::ok();
});

Route::get('/', function (Request $request) {
    $note = Note::create(['text' => $request->text]);
    return ApiResponse::created($note, 'New note created!');
});

Route::get('/api/profile', function (Request $request) {
    return ApiResponse::created(new \App\Http\Resources\User\Profile($request->user()));
});
bash
php artisan vendor:publish --provider="Gcsc\LaravelApiResponse\ApiResponseProvider" --tag="config"