PHP code example of superwen / laravel-response

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

    

superwen / laravel-response example snippets


composer 

//请求成功,输出数据,返回200
return Response::success($data);

//请求失败,系统异常,返回500
return Response::error();

//请求失败,返回200
return Response::fail();

//请求成功,返回201
return Response::created();

//请求成功,返回204
return Response::noContent();

//请求成功,返回403
return Response::forbidden();

//请求成功,返回404
return Response::notFound();

//接管异常
···
use Superwen\Response\Exceptions\JsonResponse;

class Handler extends ExceptionHandler
{
    use JsonResponse;
···