PHP code example of felo-z / laravel-api-response

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

    

felo-z / laravel-api-response example snippets


use FeloZ\LaravelApiResponse\Support\ApiCode;

api_response()->ok(['id' => 1], 'ok');
api_response()->success(['id' => 1], 'success');
api_response()->message('创建成功', ['id' => 1], 201);
api_response()->failed('参数错误', ApiCode::BIZ_FAILED, 400, ['field' => 'name']);
api_response()->exception($throwable);
bash
php artisan vendor:publish --provider="FeloZ\LaravelApiResponse\ApiResponseServiceProvider"