mivu/rscapihandler-laravel
最新稳定版本:1.0.2
Composer 安装命令:
composer require mivu/rscapihandler-laravel
包简介
simple package for handle api in laravel
README 文档
README
A simple package for handling errors, JSON templates, and repository patterns including Artisan commands.
instalation
composer require mivu/rscapihandler-laravel
Features
- Create Artisan Handlers
- Create Artisan Services
- Create Artisan Repositories
- JSON API Response Format
- Model Response Format
Basic Usage
Artisan Commands
php artisan make:repository Miftah
Output Path : App->Repositories->MiftahRepository.php AND App->Services->MiftahService.php
php artisan make:handler Miftah
Output Path : App->Handlers->MiftahHandler.php
php artisan make:enum Miftah
Output Path : App->Enums->MiftahEnum.php
Helpers
- Validation Handler
ValidationHandler::check([ 'page' => 'required|numeric', 'limit' => 'required|numeric', ]);
- Response Handler If you have implemented a service and repository, you can create an inside function for response handling.
public function limit(int $limit, $filter) { $res = $this->repository->limit($limit, $filter); return ResponseHandlers::tryCatch($res, 'miftahs', true); }
- Api Response Handlers Alternatively, you can create an API response and the output will be automatically in JSON format.
public function find($id) { try { return $this->repository->find($id); } catch (\Exception $e) { ApiHandlers::exception($e); } }
统计信息
- 总下载量: 14
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 5
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-08-06
