sedp-mis/base-api
Composer 安装命令:
composer require sedp-mis/base-api
包简介
Abstraction for api resources in laravel
README 文档
README
Abstraction for api resources in Laravel. Compatible to use with Laravel 4.2 and 5.*.
Installation
Use composer to install base-api and dependencies:
composer require sedp-mis/base-api
Introduction
The purpose of this repository is to create an abstraction for common use-cases of api resources.
It is a good practice to version our api so we will set our base api to api/v1.
So in the following api implementations, the example resource to be used is posts.
Implementation
| METHOD | URL | Description |
|---|---|---|
GET |
api/v1/posts |
@index, List of resources |
POST |
api/v1/posts |
@store, Create or store new resource |
GET |
api/v1/posts/{id} |
@show, Show resource |
| `PUT | PATCH` | api/v1/posts/{id} |
DELETE |
api/v1/posts/{id} |
@destroy, Destroy or delete resource |
Notice that @<method> are the same with the controller methods in laravel.
Advance Implementation for GET methods like @index and @show.
@index and @show
- Selective Attributes. Resource can be fetched with selective or specific fields or attributes by using query parameter
attributes[]. Example:
GET url?attributes[]=id&attributes[]=title
- Relations. Resource can be fetched with eager loaded relations by using query parameter
relations[]. Example:
GET url?relations[]=comments&relations[]=labels
- Relations Attributes. Fetched eager loaded relations can also have selective or specific attributes. Example:
GET url?relations[comments][attributes][]=id&relations[comments][attributes][]=text
@index
- Pagination. For list of resources, it is recommended to have it paginated:
GET url?page=1&per_page=100
This example shows that it is currently on the 1st page and showing 100 records per page.
Without page parameter, the list will default to all resources to be fetched.
- Filtering. It is also handy to filter list by its attributes using
filters[attribute][]parameter.
- Default:
GET url?filters[tag][]=cool&filters[tag][]=trending
- Using
equalsoperator (behaves like the default example):
GET url?filters[tag][equals][]=cool&filters[tag][equals][]=trending
- Using
not_equalsoperator:
GET url?filters[tag][not_equals][]=bug&filters[tag][not_equals][]=foo
- Searching. It is also possible to search by passing
searchquery parameter.
GET url?search[input]=SomeTextToSearch&search[compare][]=title&search[compare][]=description
- Sorting. Sorting can be done by this syntax
sort[attribute_1]=asc&sort[attribute_n]=desc. Example:
GET url?sort[title]=asc
sedp-mis/base-api 适用场景与选型建议
sedp-mis/base-api 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 99 次下载、GitHub Stars 达 0, 最近一次更新时间为 2016 年 08 月 30 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「api」 「base-api」 「laravel-api」 「api resources」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 sedp-mis/base-api 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 sedp-mis/base-api 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 sedp-mis/base-api 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
LarapiKit is a versatile and robust Laravel API package designed to simplify and enhance your web application development process. With a focus on security time saving and easy integration, this package empowers developers to streamline their API-related tasks, saving time and effort.
A PSR-7 compatible library for making CRUD API endpoints
Argonaut is a lightweight Data Transfer Object (DTO) package for Laravel that supports nested casting, recursive serialization, and validation out of the box. Ideal for service layers, APIs, and clean architecture workflows.
Easily build Eloquent queries from API requests using Alchemist Restful API.
This is my package laravel-api
A PHP SDK for Forte payment integration.
统计信息
- 总下载量: 99
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 10
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-08-30