定制 hafizmmoaz/laravel-rest-api 二次开发

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

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

hafizmmoaz/laravel-rest-api

Composer 安装命令:

composer require hafizmmoaz/laravel-rest-api

包简介

A minimal, reusable REST API toolkit for Laravel: consistent JSON responses, a typed exception hierarchy, and base API model/controller.

README 文档

README

A minimal, reusable REST API toolkit for Laravel.

Namespace: HafizMMoaz\RestApi

Provides:

  • ApiResponseApiResponse::success($data, $message) / ApiResponse::error($message, $status, $code, $details) for consistent JSON envelopes.
  • A typed exception hierarchy under HafizMMoaz\RestApi\ExceptionsApiException (base) plus ResourceNotFoundException, RelatedResourceNotFoundException, ValidationException, UnauthorizedException, UnauthenticationException. Each carries an HTTP status code and renders to a JSON error response.
  • ApiModel / ApiController — thin base classes to group API resources/endpoints.

Installation

composer require hafizmmoaz/laravel-rest-api

The service provider HafizMMoaz\RestApi\Providers\ApiServiceProvider is auto-discovered. It registers a renderer so any thrown ApiException is returned as its JSON error response automatically.

Usage

use HafizMMoaz\RestApi\ApiResponse;
use HafizMMoaz\RestApi\Exceptions\ResourceNotFoundException;

return ApiResponse::success($user, 'OK');

throw new ResourceNotFoundException('User not found');

License

MIT — see LICENSE.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-06-29

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固