PHPackages                             sircamp/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. sircamp/response

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

sircamp/response
================

a package that allows you to have a boostrap similar rest response object

1.5(10y ago)1381MITPHPPHP &gt;=5.4.0

Since Aug 11Pushed 10y ago1 watchersCompare

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

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

Sircamp Response
================

[](#sircamp-response)

This package allows you to have a "Boostrap-like" rest response object using an Alert like: Info, Warning, Error, Success.

With this package you only return the right response object to your views or your REST response, you can set the correct type of Boostrap alert without any *IF* statement. Also, on each response object that you create, you can set a message a data payload with all your data.

INSTALLATION
------------

[](#installation)

In your root project's directory type:

```
composer require sircamp/response
```

According to your composer.json, you obtain the right version (stable or dev)

USAGE
-----

[](#usage)

In each file where you are using one of the Sircamp\\Response objects you must add the right namespace.

```
use Sircamp\Response\InfoResponse as InfoResponse;
use Sircamp\Response\WarningResponse as WarningResponse;
use Sircamp\Response\SuccessResponse as SuccessResponse;
use Sircamp\Response\DangerResponse as DangerResponse;
```

### new Response

[](#new-response)

To create new Response object ( InfoResponse for example ) you need two parameters.

A String message, that could be empty, and an array named data.

The data array could contain everthing you want, object, string and much more.

Pay attention that each type of object has automatically set the **type** string parameter:

- In case of **InfoResponse** the **type** attribute is setted to **info**
- In case of **WarningResponse** the **type** attribute is setted to **warning**
- In case of **SuccessResponse** the **type** attribute is setted to **success**
- In case of **DangerResponse** the **type** attribute is setted to **danger**

```
$data = [
    'object' => new Object('example'),
    'number' => 1,
    'string' => "hello world"
    //etc
];

$message = "I want to say hello world";

$infoResponse = new InfoResponse($data,$message);
```

### getType

[](#gettype)

This method returns the type of object's istance

```
$infoResponse->getType();
```

### setType

[](#settype)

This method sets the type of the object

```
$infoResponse->setType($type);
```

### getMessage

[](#getmessage)

This method returns the message attribute of of the object

```
$infoResponse->getMessage();
```

### setMessage

[](#setmessage)

This method sets the message attribute of of the object

```
$message = "I want to say hello world";
$infoResponse->setMessage($message);
```

### getData

[](#getdata)

This method returns the data attribute of of the object

```
$infoResponse->getData();
```

### setData

[](#setdata)

This method sets the data attribute of of the object. As seed the $data parameters is an associative array that contains a mixin of variable

```
$data = [
    'object' => new Object('example'),
    'number' => 1,
    'string' => "hello world"
    //etc
];
$infoResponse->setData($data);
```

### addAllowedType

[](#addallowedtype)

This method is a static method that allows you to add a castum response type. If you add a custom type, you can create a new extended custom class ( with your desidered type ) at runtime.

**To create an anonymous runtime class you must have PHP 7**

```
$type = "custom";
BaseResponse::addAllowedType($type);
```

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 90% 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 ~4 days

Total

6

Last Release

3910d ago

### Community

Maintainers

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

---

Top Contributors

[![sirCamp](https://avatars.githubusercontent.com/u/7548001?v=4)](https://github.com/sirCamp "sirCamp (9 commits)")[![NickyBass](https://avatars.githubusercontent.com/u/231980?v=4)](https://github.com/NickyBass "NickyBass (1 commits)")

---

Tags

responsejsonsymfonylaravelrestbootstrap

### Embed Badge

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

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

###  Alternatives

[givebutter/laravel-keyable

Add API keys to your Laravel models

187144.5k2](/packages/givebutter-laravel-keyable)[guanguans/laravel-api-response

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

485.6k](/packages/guanguans-laravel-api-response)

PHPackages © 2026

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