LaravelPackages.net
Acme Inc.
Toggle sidebar
reasonpun/laravel-quick-tools

agile development

7
1
v0.0.3
About reasonpun/laravel-quick-tools

reasonpun/laravel-quick-tools is a Laravel package for agile development. It currently has 1 GitHub stars and 7 downloads on Packagist (latest version v0.0.3). Install it with composer require reasonpun/laravel-quick-tools. Discover more Laravel packages by reasonpun or browse all Laravel packages to compare alternatives.

Last updated

laravel-quick

laravel-quick-tools 封装了一些我们开发中常见的工具,使开发变得更高效 forked from youyingxiang/laravel-quick & fit for Laravel 9.x

安装

  • composer require reasonpun/laravel-quick-tools

  • 生成翻译好的中文包命令

    linux 和 mac php artisan vendor:publish--provider="Reasonpun\\LaravelQuickTools\\LaravelQuickToolsServiceProvider" windows php artisan vendor:publish --provider="Reasonpun\LaravelQuickTools\LaravelQuickToolsServiceProvider"

怎么使用

// api 返回状态码 // 异常使用例子 use Reasonpun\LaravelQuickTools\Exceptions\Api\ApiNotFoundException; // 请求参数错误 throw new ApiRequestException(); // 404 未找到 throw new ApiNotFoundException(); // 系统错误 throw new ApiSystemException() // 未授权 throw new ApiUnAuthException() // 返回 //自定义错误继承Reasonpun\LaravelQuickTools\Exceptions自己参照对应代码自定义 // api接口使用 use Reasonpun\LaravelQuickTools\Traits\JsonResponseTrait // 成功 return $this->success("消息",['name'=>"张三"]); // 失败 return $this->error("错误"); // 自定义 return $this->apiResponse(Response::HTTP_BAD_GATEWAY,"502错误"); // 缓存的使用(封装了redis的一些方法) use Reasonpun\LaravelQuickTools\Facades\CacheClient; CacheClient::hSet("test","1","张三"); CacheClient::hGet("test","1"); CacheClient::lPush("test","1"); 具体参考Reasonpun\LaravelQuickTools\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
Comments