PHPackages                             guanguans/laravel-api-response - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. guanguans/laravel-api-response

ActiveLibrary[HTTP &amp; Networking](/categories/http)

guanguans/laravel-api-response
==============================

Normalize and standardize Laravel API response data structure. - 规范化和标准化 Laravel API 响应数据结构。

3.2.0(1mo ago)485.6k↑62.9%2MITPHPPHP &gt;=8.1CI passing

Since Aug 23Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/guanguans/laravel-api-response)[ Packagist](https://packagist.org/packages/guanguans/laravel-api-response)[ Docs](https://github.com/guanguans/laravel-api-response)[ Fund](https://guanguans.github.io/sponsors)[ RSS](/packages/guanguans-laravel-api-response/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (60)Versions (36)Used By (0)

laravel-api-response
====================

[](#laravel-api-response)

> Normalize and standardize Laravel API response data structure. - 规范化和标准化 Laravel API 响应数据结构。

[![tests](https://github.com/guanguans/laravel-api-response/actions/workflows/tests.yml/badge.svg)](https://github.com/guanguans/laravel-api-response/actions/workflows/tests.yml)[![php-cs-fixer](https://github.com/guanguans/laravel-api-response/actions/workflows/php-cs-fixer.yml/badge.svg)](https://github.com/guanguans/laravel-api-response/actions/workflows/php-cs-fixer.yml)[![codecov](https://camo.githubusercontent.com/18a9143c97e9eb0a24762f01ed2d0947dddc0fab811df2b340664c78450b5bb6/68747470733a2f2f636f6465636f762e696f2f67682f6775616e6775616e732f6c61726176656c2d6170692d726573706f6e73652f6272616e63682f6d61696e2f67726170682f62616467652e7376673f746f6b656e3d55524746415753365334)](https://codecov.io/gh/guanguans/laravel-api-response)[![Latest Stable Version](https://camo.githubusercontent.com/74f65d09f31f492a21a7744b86a32ec1c4a58305c82445b60636e797d54e5d48/68747470733a2f2f706f7365722e707567782e6f72672f6775616e6775616e732f6c61726176656c2d6170692d726573706f6e73652f76)](https://packagist.org/packages/guanguans/laravel-api-response)[![GitHub release (with filter)](https://camo.githubusercontent.com/9b55573dc79a5ed492951079e708cbf149ab93dfbe678b337a577daf32a038aa/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f72656c656173652f6775616e6775616e732f6c61726176656c2d6170692d726573706f6e7365)](https://github.com/guanguans/laravel-api-response/releases)[![Total Downloads](https://camo.githubusercontent.com/3174d829d70b2f2386ce447824850647a3cb3cdf5384344f4471e56b0bfbc272/68747470733a2f2f706f7365722e707567782e6f72672f6775616e6775616e732f6c61726176656c2d6170692d726573706f6e73652f646f776e6c6f616473)](https://packagist.org/packages/guanguans/laravel-api-response)[![License](https://camo.githubusercontent.com/044456f3110c545710f992bb26fb0ddf9d7847574677d25333ad343c584be562/68747470733a2f2f706f7365722e707567782e6f72672f6775616e6775616e732f6c61726176656c2d6170692d726573706f6e73652f6c6963656e7365)](https://packagist.org/packages/guanguans/laravel-api-response)

Features
--------

[](#features)

- Support for customized response data structure
- Support for restful API response(optional)
- Support for automatically handled api exception
- Support for localized message
- Support for customized [pipe](src/Pipes/)(Process api response structure through pipeline)
- Support for customized [exception pipe](src/ExceptionPipes/)(Convert exception to api response through pipeline)

Requirement
-----------

[](#requirement)

- PHP &gt;= 8.1

Installation
------------

[](#installation)

```
composer require guanguans/laravel-api-response --ansi -v
```

Configuration
-------------

[](#configuration)

### Publish files(optional)

[](#publish-filesoptional)

```
php artisan vendor:publish --provider="Guanguans\\LaravelApiResponse\\ServiceProvider" --ansi -v
```

Usage
-----

[](#usage)

### Quick start

[](#quick-start)

```
