PHPackages                             dev-toolbelt/jsend-payload - 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. dev-toolbelt/jsend-payload

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

dev-toolbelt/jsend-payload
==========================

A framework-agnostic PHP library for building standardized JSend API responses with PSR-7 support

1.0.2(3mo ago)24261MITPHPPHP ^8.1CI passing

Since Feb 1Pushed 3mo agoCompare

[ Source](https://github.com/Dev-Toolbelt/jsend-payload)[ Packagist](https://packagist.org/packages/dev-toolbelt/jsend-payload)[ Docs](https://github.com/Dev-Toolbelt/jsend-payload)[ RSS](/packages/dev-toolbelt-jsend-payload/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (3)Dependencies (7)Versions (4)Used By (1)

JSend Payload
=============

[](#jsend-payload)

[![CI](https://github.com/dev-toolbelt/jsend-payload/actions/workflows/ci.yml/badge.svg)](https://github.com/dev-toolbelt/jsend-payload/actions/workflows/ci.yml)[![Coverage](https://camo.githubusercontent.com/8c06ad3049df2e933ea245bb2d6e129481519290e540e9081a77ba4d26eac836/68747470733a2f2f636f6465636f762e696f2f67682f6465762d746f6f6c62656c742f6a73656e642d7061796c6f61642f6272616e63682f6d61696e2f67726170682f62616467652e737667)](https://codecov.io/gh/dev-toolbelt/jsend-payload)[![Latest Stable Version](https://camo.githubusercontent.com/19b18c6da51ecec0b338d85e23e292c1cfc1fd32d7d18d8cdcd6411f0780dae9/68747470733a2f2f706f7365722e707567782e6f72672f6465762d746f6f6c62656c742f6a73656e642d7061796c6f61642f762f737461626c65)](https://packagist.org/packages/dev-toolbelt/jsend-payload)[![Total Downloads](https://camo.githubusercontent.com/43d12f8ba0f24af1bc081d9a3258d5cc623355f1f75a813f24037b2cd3f23195/68747470733a2f2f706f7365722e707567782e6f72672f6465762d746f6f6c62656c742f6a73656e642d7061796c6f61642f646f776e6c6f616473)](https://packagist.org/packages/dev-toolbelt/jsend-payload)[![License](https://camo.githubusercontent.com/f7af4ad125b1a2746ba5a70be274930c38173453e2f09e58a0a16e99f6129c99/68747470733a2f2f706f7365722e707567782e6f72672f6465762d746f6f6c62656c742f6a73656e642d7061796c6f61642f6c6963656e7365)](https://packagist.org/packages/dev-toolbelt/jsend-payload)[![PHP Version](https://camo.githubusercontent.com/5f63764b9401b1f021dacb08dc958546e36b7fc5e5f55d662336b7bef1b446fb/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6465762d746f6f6c62656c742f6a73656e642d7061796c6f6164)](https://packagist.org/packages/dev-toolbelt/jsend-payload)

A framework-agnostic PHP library for building standardized API responses following the [JSend specification](https://github.com/omniti-labs/jsend). Provides a simple trait that can be mixed into any controller or handler to generate consistent JSON responses with PSR-7 support.

Features
--------

[](#features)

- **Framework Independence** - Works with Laravel, Symfony, Slim, Mezzio, or any PSR-7 compatible framework
- **JSend Compliant** - Follows the JSend specification for standardized API responses
- **PSR-7 Support** - Returns `Psr\Http\Message\ResponseInterface` for maximum interoperability
- **Type-Safe HTTP Codes** - Uses enums for HTTP status codes, preventing invalid values
- **Common Response Helpers** - Pre-built methods for validation errors, not found, empty payloads, and more
- **Zero Configuration** - Just use the trait and start returning standardized responses

Requirements
------------

[](#requirements)

- PHP 8.1 or higher

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

[](#installation)

```
composer require dev-toolbelt/jsend-payload
```

Quick Start
-----------

[](#quick-start)

Add the `AnswerTrait` to your controller and start returning standardized responses:

```
