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

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

youngmayor/app-response
=======================

A laravel package for providing unified easy to use response to our laravel applicatons

1.1.0(3y ago)093MITPHPPHP ^7.2|^8.0

Since Nov 23Pushed 3y ago1 watchersCompare

[ Source](https://github.com/YoungMayor/laravel-app-response)[ Packagist](https://packagist.org/packages/youngmayor/app-response)[ Docs](https://github.com/youngmayor/laravel-app-response)[ RSS](/packages/youngmayor-app-response/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (2)Dependencies (3)Versions (4)Used By (0)

Laravel App Response
====================

[](#laravel-app-response)

[![Latest Version on Packagist](https://camo.githubusercontent.com/39807fe4378b7dcc0f5e999d6583805b084c99bba597662f21854ddd1a1080c4/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f796f756e676d61796f722f6170702d726573706f6e73652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/youngmayor/app-response)[![Total Downloads](https://camo.githubusercontent.com/4efc47c21a89ad8552673efb48eca080cb6d58ea3ea3911793516e5f5d5957ed/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f796f756e676d61796f722f6170702d726573706f6e73652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/youngmayor/app-response)[![GitHub Actions](https://github.com/youngmayor/app-response/actions/workflows/main.yml/badge.svg)](https://github.com/youngmayor/app-response/actions/workflows/main.yml/badge.svg)

This is a simple laravel package for providing a unified response for our application.

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

[](#installation)

You can install the package via composer:

```
composer require youngmayor/app-response
```

Usage
-----

[](#usage)

The package uses auto discovery hence if you use Laravel 5.5 or above, installing the package automatically registers it in your application.

However, if you use Laravel 5.4 or below you will need to add the below snipet to your `config/app.php` to register the Service Provider and alias

```
'providers' => [
    // ...
    YoungMayor\AppResponse\AppResponseServiceProvider,
    // ...
],

'aliases' => [
    // ...
    "AppResponse": "YoungMayor\AppResponse\Facade\AppResponse"
    // ...
],
```

The package can now be added to our controller actions using one of the methdos below

1. Injecting the API response helper

```
// ...
use YoungMayor\AppResponse\API;
// ...

class SampleController extends Controller
{
    public function sampleMethod(API $api)
    {
        // ...
        return $api->success("Action was successful");
    }
}
```

2. Injecting the Web response helper

```
// ...
use YoungMayor\AppResponse\Web;
// ...

class SampleController extends Controller
{
    public function sampleMethod(Web $web)
    {
        // ...
        return $web->success("Action was successful");
    }
}
```

3. Injecting the automatic response helper

```
// ...
use YoungMayor\AppResponse\Auto;
// ...

class SampleController extends Controller
{
    public function sampleMethod(Auto $auto)
    {
        // ...
        return $auto->success("Action was successful");
    }
}
```

4. Using the package facade

```
// ...
use YoungMayor\AppResponse\Facade\AppResponse;
// or
use AppReponse; // this utilises the Facade aliase
// ...

class SampleController extends Controller
{
    public function sampleMethod()
    {
        // ...
        return AppResponse::success("Action was successful");
    }
}
```

5. Using the helper function

```
class SampleController extends Controller
{
    public function sampleMethod()
    {
        // ...
        return appResponse()->success("Action was successful"); // for automatic response
        // or
        return appResponse()->api->success("Action was successful"); // for API only resppnse
        // or
        return appResponse()->web->success("Action was successful"); // for Web only resppnse
    }
}
```

Response Types
--------------

[](#response-types)

The package provides two forms of responses, Web and API. It also provides an Auto responder which essentially responds as API if `Accept: application/json` header exists and responds as Web if the header is missing.

### API Response

[](#api-response)

This returns a JSON response

**Example**

```
{
    "status": "success",
    "statusCode": 200,
    "message": "Action was successful",
    "data": {
        "name": "Foo Bar",
        "email": "foobar@example.com"
    }
}
```

### Web Response

[](#web-response)

This renders a web page as the response. An example is attached below [![Screenshot](/resources/screenshots/web-response.png)](/resources/screenshots/web-response.png)

> Web response can be completed turned off by making setting the `app-response.render-web-as-view` configuration to false. The configuration file can be published using the below command
>
> ```
> php artisan vendor:publish --provider="YoungMayor\AppResponse\AppResponseServiceProvider" --tag="config"
> ```

The web response can also be customised. To publish the views run the below code on the root of your application terminal

```
php artisan vendor:publish --provider="YoungMayor\AppResponse\AppResponseServiceProvider"
```

### Changelog

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

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

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

### Security

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Meyoron Aghogho](https://github.com/youngmayor)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

Laravel Package Boilerplate
---------------------------

[](#laravel-package-boilerplate)

This package was generated using the [Laravel Package Boilerplate](https://laravelpackageboilerplate.com).

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity57

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

Total

3

Last Release

1405d ago

### Community

Maintainers

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

---

Top Contributors

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

---

Tags

youngmayorapp-response

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[barryvdh/laravel-ide-helper

Laravel IDE Helper, generates correct PHPDocs for all Facade classes, to improve auto-completion.

14.9k123.0M687](/packages/barryvdh-laravel-ide-helper)[orchestra/canvas

Code Generators for Laravel Applications and Packages

21017.2M158](/packages/orchestra-canvas)[illuminate/pipeline

The Illuminate Pipeline package.

9446.6M213](/packages/illuminate-pipeline)[illuminate/pagination

The Illuminate Pagination package.

10532.5M862](/packages/illuminate-pagination)[spatie/laravel-pjax

A pjax middleware for Laravel 5

513371.8k11](/packages/spatie-laravel-pjax)[spatie/laravel-mix-preload

Add preload and prefetch links based your Mix manifest

169176.0k2](/packages/spatie-laravel-mix-preload)

PHPackages © 2026

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