jeybin / apiresponse
Laravel API 响应助手
v1.5
2023-01-11 08:30 UTC
This package is auto-updated.
Last update: 2024-09-11 17:00:06 UTC
README
安装
您可以通过 composer 安装此包
composer require jeybin/apiresponse
要发布供应商并复制配置文件,请运行
php artisan apiresponse:install
用法
如果您想以数组形式获取响应,可以使用
\Jeybin\Apiresponse\ThrowResponse::status(200) ->message('User defined message') ->get(['can send array or string or empty'])
否则,如果您想抛出响应,可以使用
\Jeybin\Apiresponse\ThrowResponse::status(200) ->message('User defined message') ->throw(['can send array or string or empty'])
无消息
\Jeybin\Apiresponse\ThrowResponse::status(200) ->throw(['can send array or string or empty'])
\Jeybin\Apiresponse\ThrowResponse::status('success')->throw()
一些状态码已在 config/jeybin-apiresponse.php 文件中定义,如果您想添加更多,请更新该文件