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

ActiveLibrary

fojuth/response-exception
=========================

Response exception for Laravel4

1.1.0(12y ago)061MITPHPPHP &gt;=5.3.0

Since May 15Pushed 11y ago1 watchersCompare

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

READMEChangelogDependencies (2)Versions (5)Used By (0)

Response Exception
------------------

[](#response-exception)

Response exception for Laravel4 is.. exception which returns response.

Install notes
-------------

[](#install-notes)

Add `desmart/response-exception` as a requirement to composer.json:

```
{
  "require": {
    "desmart/response-exception": "1.1.*"
  }
}
```

Update your packages with `composer update` or install with `composer install`.

To add error handler add `'DeSmart\ResponseException\ResponseExceptionServiceProvider',` to providers in `app/config/app.php`.

Other way of adding the handler is to add `App::error()` in `app/filters.php`:

```
App::error(DeSmart\ResponseException\ErrorHandlerFactory::make());
```

Just remember to add it **after** the registration of other `App::error()` handlers.

Why ?
-----

[](#why-)

Let's take a look at [desmart/laravel-layout](https://github.com/DeSmart/laravel-layout). It's a complex controller calling many actions.

Doing redirects in one of the actions is quite painful. That's because each action returns only a part of *bigger* response. The only way to return a response which will overwrite the *big part* is throwing of exception.

That's not the best design (exceptions aren't for that!), but it works and gives a chance to generate complete response from the smallest part of application.

Use cases
---------

[](#use-cases)

This package is useless for *standard* Laravel applications. Probably it fit's best with [desmart/laravel-layout](https://github.com/DeSmart/laravel-layout) since it's a wicked controller.

Also in some edge cases it can be used for situations when some part of application **needs** to send own response during controller dispatch.

Examples
--------

[](#examples)

```
use DeSmart\ResponseException\Exception as ResponseException;

ResponseException::make('foo'); // sends 'foo' response

// There's an option to make chained exceptions
ResponseException::chain(Redirect::to('/'))
  ->withInput()
  ->fire();
```

The hack
--------

[](#the-hack)

In Laravel response may by returned in many parts of request cycle:

- before routing (`App::before()`)
- during route dispatch
- when exception is thrown (`App::error`)

Our hack is using exceptions to take advantage of `App::error()`. When error handler returns a value that value is treated as a response and is returned to client.

Since throwing an exception breaks normal code execution it's the best way to deliver fast a response.

There's a catch. Every exception is logged to file. The only way to get pass it is to register error handler **as the last one**. Laravel puts every error handler on top of handlers stack. When one of them returns response the others are not called.

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 80% 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 ~281 days

Total

2

Last Release

4469d ago

### Community

Maintainers

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

---

Top Contributors

[![radmen](https://avatars.githubusercontent.com/u/1190255?v=4)](https://github.com/radmen "radmen (8 commits)")[![fojuth](https://avatars.githubusercontent.com/u/2622146?v=4)](https://github.com/fojuth "fojuth (2 commits)")

### Embed Badge

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

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

###  Alternatives

[fumeapp/modeltyper

Generate TypeScript interfaces from Laravel Models

196277.9k](/packages/fumeapp-modeltyper)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)

PHPackages © 2026

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