whiteki/simple-api-response

简单封装 API 响应

0.0.5 2020-08-13 05:07 UTC

This package is auto-updated.

Last update: 2024-09-13 14:43:49 UTC


README

根据《手把手教你让 Laravel 开发 API 更得心应手》文章所写 https://learnku.com/articles/25947#9ea6b3

sql日志记录为 https://github.com/overtrue/laravel-query-logger

方便个人使用

包含

  • make:service

安装中

$ composer require whiteki/simple-api-response

用法

  1. 修改 bootstrap/app.php 文件下绑定的异常处理类
$app->singleton(
    Illuminate\Contracts\Debug\ExceptionHandler::class,
    \Whiteki\SimpleApiResponse\Exceptions\Handler::class
);
  1. 在 controller 里使用 trait
use \Whiteki\SimpleApiResponse\ApiResponse;
  1. 新增 channel sqllog
'sqllog' => [
    'driver' => 'daily',
    'path' => storage_path('logs/sql.log'),
    'level' => 'debug',
    'days' => 14,
];