PHPackages                             farhanwazir/makeresponse - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. farhanwazir/makeresponse

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

farhanwazir/makeresponse
========================

Make Response Schema Responder.

v1.5.4(9y ago)2331MITPHPPHP &gt;=5.4

Since Apr 1Pushed 9y ago1 watchersCompare

[ Source](https://github.com/farhanwazir/makeresponse)[ Packagist](https://packagist.org/packages/farhanwazir/makeresponse)[ RSS](/packages/farhanwazir-makeresponse/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (7)Dependencies (1)Versions (8)Used By (0)

Make Response
=============

[](#make-response)

This PHP library helps to generate global standard response in `JSON` and `Array` for client (API Client, POS Client, Web Client etc). It is not framework dependent, you are open to use it with any PHP project.

#### Why to use this library

[](#why-to-use-this-library)

- This library is a standard formatted schema to response, you don't need to make a document for every web service, just refer to this.
- This library works logically, you must respect standards.
- It is framework free and if you want it to use with any framework then you can. It has Laravel &amp; Lumen build-in support as described below.

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

[](#installation)

Via composer command

```
composer require farhanwazir/makeresponse

```

Or add below line in your composer.json and run `composer update` command

```
"farhanwazir/makeresponse" : "1.*"
```

Laravel &amp; Lumen Configuration
---------------------------------

[](#laravel--lumen-configuration)

### Laravel user's

[](#laravel-users)

For Laravel user's can add below line in config/app.php

```
'providers' => [
    ...
    FarhanWazir\MakeResponse\MakeResponseServiceProvider::class
    ...
]
```

Do not close config/app, go down inside "aliases"

```
'aliases' => [
    ...
    'MakeResponse' => FarhanWazir\MakeResponse\Facade\MakeResponse::class
    ...
]
```

### Lumen user's

[](#lumen-users)

For Lumen user's can add below line in bootstrap/app.php

```
$app->register(FarhanWazir\MakeResponse\MakeResponseServiceProvider::class);
```

Add alias as facade in laravel

```
if (!class_exists('MakeResponse')) {
    class_alias(FarhanWazir\MakeResponse\Facade\MakeResponse::class, 'MakeResponse');
}
```

Usage
-----

[](#usage)

You just need to call `makeResponse()` helper function to respond to request. Below listed available methods will help you to explorer MakeResponse.

- `setStatus(numeric)` set numeric value with positive or negative
- `setMessage(string)` set string message not big string, it is for short message
- `setErrors(sting|array)` set string or array for errors
- `setResult(string|array)` set string or array for result parameter of your response
- `set(status, result, errors, message)` set method for set response parameters once
- `get()` get formatted response collection
- `get()->toArray()` convert collection in array
- `get()->toJson()` convert collection in json

#### Use via helper function

[](#use-via-helper-function)

```
makeResponse($status, $result, $errors, $message, $array);
```

- `$status` must be numeric positive or negative.
- `$result` string or array. `Default null`
- `$errors` string or array. `Default null`
- `$message` one line string. `Default null`
- `$array` boolean, it is belongs to returning response (in array or json). `Default true`

#### Get response example

[](#get-response-example)

Example 1: Get formatted response in array

```
makeResponse(1, ['id' => 1, 'name' => 'Farhan Wazir']);

/** Output
[
    'status' => 1,
    'result' => ['id' => 1, 'name' => 'Farhan Wazir']
]
*/
```

Example 2: Get formatted response in json

```
makeResponse()->setStatus(0)->setErrors('You provided input is wrong.')->get();
/** Output
{
    'status' : 0,
    'errors' : ['You provided input is wrong.']
}
*/

//OR
makeResponse(1, ['id' => 1, 'name' => 'Farhan Wazir'], null, null, false);
/** Output
{
    'status' : 1,
    'errors' : ['id' => 1, 'name' => 'Farhan Wazir']
}
*/
```

Example 3: Verify formatted response to client

```
//Response will be in array
makeResponse(1);
/** Output
[
    'status' => 1
]
*/

//Response will be in json
makeResponse(1, null, null, null, false);
/** Output
{
    'status' : 1
}
*/
```

Example 4: Convert response in array

```
// makeResponse()->toArray() converts into array and same for json by toJson()
makeResponse()->setStatus(0)->setErrors('You provided input is wrong.')->get()->toArray();
```

Example 5: Direct class call approach

```
$response = new FarhanWazir\MakeResponse\Response();
$response->setStatus(1)->setMessage('Make you feel comfortable');
$response->setResult( array('id' => 1, 'name' => 'Make Responder') );

print $response->get(); //or $response->get()->toJson();
/** Output
{
    'status' : 1,
    'message' : 'Make you feel comfortable',
    'result' : ['id' => 1, 'name' => 'Make Responder']
}
*/

//convert response in array
print_r($response->get()->toArray());
[
    'status' => 1,
    'message' => 'Make you feel comfortable',
    'result' => ['id' => 1, 'name' => 'Make Responder']
]
```

**Laravel and Lumen user's**

You can also use above illustrated example and below is for Laravel and Lumen style:

```
//Response will be in json
MakeResponse::set(1, ['id' => 1, 'name' => 'Farhan Wazir'])->get();

//Response will be in array
MakeResponse::set(0, null, 'Your input is wrong', 'Input error')->get()->toArray();
```

### Thank you for using

[](#thank-you-for-using)

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity63

Established project with proven stability

 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 ~1 days

Total

7

Last Release

3325d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/d8e56eaa7647e429f12cfde6159e42059c4038f9009860a774808db5cdaf2cce?d=identicon)[farhanwazir](/maintainers/farhanwazir)

---

Top Contributors

[![farhanwazir](https://avatars.githubusercontent.com/u/241825?v=4)](https://github.com/farhanwazir "farhanwazir (17 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/farhanwazir-makeresponse/health.svg)

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

###  Alternatives

[nativephp/php-bin

PHP binaries used by the NativePHP framework

135186.9k3](/packages/nativephp-php-bin)[chrisharrison/php-array-of

Implement an array of a defined type. Generics replacement for PHP.

11722.4k2](/packages/chrisharrison-php-array-of)

PHPackages © 2026

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