PHPackages                             athosbenther/laravelapiresponses - 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. [API Development](/categories/api)
4. /
5. athosbenther/laravelapiresponses

ActiveLibrary[API Development](/categories/api)

athosbenther/laravelapiresponses
================================

This package is intend to help create standardized JSON responses using Laravel | PHP applications.

0.2.4(1y ago)2320[2 issues](https://github.com/AthosBenther/LaravelApiResponses/issues)MITPHPPHP ^8.3.0

Since Sep 21Pushed 1y ago1 watchersCompare

[ Source](https://github.com/AthosBenther/LaravelApiResponses)[ Packagist](https://packagist.org/packages/athosbenther/laravelapiresponses)[ Fund](https://www.paypal.com/donate/?hosted_button_id=KUGH5KXT4X32W)[ RSS](/packages/athosbenther-laravelapiresponses/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (5)Dependencies (3)Versions (11)Used By (0)

Laravel(?) API Responses
========================

[](#laravel-api-responses)

This package is intend to help create standardized JSON responses using Laravel | PHP applications.

### Example Response Structure

[](#example-response-structure)

```
{
    "message": "User retrieved!",
    "data": {
        "Name": "Jhon Doe"
    },
    "status": {
        "code": 200,
        "message": "OK"
    },
    "meta": {
        "timestamp": "2024-09-21 14:36:24"
    }
}
```

Instalation
-----------

[](#instalation)

### Requirements

[](#requirements)

- PHP 8.3+

Install with composer:

```
composer require athosbenther/laravelapiresponses
```

Usage
-----

[](#usage)

Add the trait `ApiResponses` to your class and use it to generate default responses. Or create a new `ApiResponse` directly.

The return class `ApiResponse` inherits from `Symfony\Component\HttpFoundation\Response`, and can be further configured using it's functions.

### Using the Trait

[](#using-the-trait)

```
