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

ActiveLibrary[API Development](/categories/api)

pedre/response
==============

Standard json response structure

v1.0.1(4y ago)41.5kMITPHP

Since Oct 22Pushed 4y ago2 watchersCompare

[ Source](https://github.com/pedramre/pedre-response)[ Packagist](https://packagist.org/packages/pedre/response)[ Docs](http://github.com)[ RSS](/packages/pedre-response/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)DependenciesVersions (3)Used By (0)

PedreResponse
=============

[](#pedreresponse)

It's very important to use same structure for responses in large projects that **PedreResponse** package can do it for you.

PedreResponse is a starndard json response structure.

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

[](#installation)

Use the package manager [composer](https://getcomposer.org) to install PedreResponse.

```
composer require pedre/response
```

Usage
-----

[](#usage)

```
  $response = new Response();

  // set boolean 'success'. It's optional (default is true)
  $response->setSuccess();

  // set array 'data'. It's optional (default is empty array)
  $response->setData();

  // set array 'message'. It's optional (default is empty string)
  $response->setMessage();

  // set integer 'error_code'. It's optional
  $response->setErrorCode();

  // set integer 'status'. It's optional (default is 200)
  $response->setStatus();

  // send json response. It's required
  $response->send();
```

Full Example
------------

[](#full-example)

```
use Pedre\Response\Response;

class UserController extends Controller
{
   public function login(Request $request,Response $response){
        $validator = Validator::make($input, [
            'email' => 'required|email',
            'password' => 'required'
        ]);
        if ($validator->fails()) {
            return  $response->setSuccess(false)
                ->setMessage('Please Enter Valid Character')
                ->setErrorCode(400)
                ->setData(['errorMessages'=>$validator->messages()])
                ->send();
        }

        if (Auth::attempt(['email' => $input['email'], 'password' => $input['password']],'web')) {
            return  $response->setMessage('Successful Login, Congratulations !!!')->send();
        }
        else{
            return  $response->setSuccess(false)
                ->setMessage('There is not any user, Please register')
                ->send();
        }

   }
}
```

Contributing
------------

[](#contributing)

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License
-------

[](#license)

[MIT](https://choosealicense.com/licenses/mit/)

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~61 days

Total

2

Last Release

1608d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/40c86145894b802c08d6798ad6f86e97fb8a11919157adac8796fcf615ec444f?d=identicon)[pedramre](/maintainers/pedramre)

---

Top Contributors

[![pedramre](https://avatars.githubusercontent.com/u/53277424?v=4)](https://github.com/pedramre "pedramre (7 commits)")

---

Tags

responsephpjsonapilaravel

### Embed Badge

![Health badge](/badges/pedre-response/health.svg)

```
[![Health](https://phpackages.com/badges/pedre-response/health.svg)](https://phpackages.com/packages/pedre-response)
```

###  Alternatives

[obiefy/api-response

Simple Laravel package to return Json responses.

17324.6k](/packages/obiefy-api-response)[wayofdev/laravel-symfony-serializer

📦 Laravel wrapper around Symfony Serializer.

2113.6k](/packages/wayofdev-laravel-symfony-serializer)[nilportugues/laravel5-json-api-dingo

Laravel5 JSONAPI and Dingo together to build APIs fast

311.5k](/packages/nilportugues-laravel5-json-api-dingo)[nilportugues/laravel5-haljson

Laravel 5 HAL+JSON API Transformer Package

151.0k](/packages/nilportugues-laravel5-haljson)[nicklaw5/larapi

A simple Laravel 5 class for handling json api responses.

111.5k](/packages/nicklaw5-larapi)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
