![b9d132d823e84e7b02395e701118b04f.png](https://i-blog.csdnimg.cn/blog_migrate/ad1e0e57766c603cb8911da55e9c6e68.jpeg)
php中文网最新课程
每日17点准时技术干货分享
![4e721ab2c4563a34dc10bac547239323.png](https://i-blog.csdnimg.cn/blog_migrate/9e83fc6ed06614b79ac750036118e49e.jpeg)
laravel-quick
laravel-quick(github 地址:https://github.com/youyingxiang/laravel-quick.git)
封装了一些我们开发中常见的工具,使开发变得更高效
主要包含翻译了验证的语言包提示
根据 Symfony\Component\HttpFoundation\Response 为状态码的接口格式
异常类处理
集成基于 redis 的各种缓存操作
service,repository,trait的 artisan 命令生成;
安装
composer require yxx/laravel-quick
linux 和 mac
php artisan vendor:publish --provider="Yxx\\LaravelQuick\\LaravelQuickServiceProvider"
windows
php artisan vendor:publish --provider="Yxx\LaravelQuick\LaravelQuickServiceProvider"
怎么使用
异常使用例子
use Yxx\LaravelQuick\Exceptions\Api\ApiNotFoundException;// 请求参数错误throw new ApiRequestException();// 404 未找到throw new ApiNotFoundException();// 系统错误throw new ApiSystemException()// 未授权throw new ApiUnAuthException()自定义错误继承Yxx\LaravelQuick\Exceptions自己参照对应代码自定义
api 接口使用
use Yxx\LaravelQuick\Traits\JsonResponseTrait// 成功return $this->success("消息",['name'=>"张三"]);// 失败return $this->error("错误");// 自定义return $this->apiResponse(Response::HTTP_BAD_GATEWAY,"502错误");
缓存的使用(封装了 redis 的一些方法)
use Yxx\LaravelQuick\Facades\CacheClient;CacheClient::hSet("test","1","张三");CacheClient::hGet("test","1");CacheClient::lPush("test","1");具体参考Yxx\LaravelQuick\Services\CacheService里面的方法....
artisan 命令
创建 Trait php artisan quick:create-trait test创建 Service php artisan quick:create-service Test/TestService创建 Repository php artisan quick:create-repository Test
▼