定制 mivu/rscapihandler-laravel 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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);
        }
    }

Here's an example of the output: output

统计信息

  • 总下载量: 14
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 5
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 5
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-08-06