PHPackages                             oguz-yilmaz/trammel - 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. [Logging &amp; Monitoring](/categories/logging)
4. /
5. oguz-yilmaz/trammel

ActiveLibrary[Logging &amp; Monitoring](/categories/logging)

oguz-yilmaz/trammel
===================

Provides distinct exception handlers for Laravel

v1.0.0(3y ago)09MITPHPPHP &gt;=8.0

Since Jun 26Pushed 3y ago1 watchersCompare

[ Source](https://github.com/oguz-yilmaz/trammel)[ Packagist](https://packagist.org/packages/oguz-yilmaz/trammel)[ Docs](https://github.com/oguz-yilmaz/trammel)[ RSS](/packages/oguz-yilmaz-trammel/feed)WikiDiscussions master Synced 3d ago

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

### About Trammel

[](#about-trammel)

Handling exceptions is vital for all sorts of applications. Making it right and standardized increases the quality of your application as well as making it easy to reason about. In laravel there is not much configuration you can apply and there is only one place where you construct all your exceptions, that is the `Handler.php`. With the need of custom exception handling this file becomes pretty ugly real quick having if-else statements all over the place.This library provides default exception handling and standardized output formats for different types of exceptions (`Validation exceptions`, `Ajax or Json exceptions` or `combined`) as well as distict handlers for each where you can extend and customize.

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

[](#installation)

`composer require oguz-yilmaz/trammel`

Version Compatibility
---------------------

[](#version-compatibility)

LaravelPHPTrammel7.x8.0+1.xException handler types and default output formats
--------------------------------------------------

[](#exception-handler-types-and-default-output-formats)

Trammel provides generic handlers for most situation. Each handler provides generic output formats that can be extended. See below for what they refer and what they offer as response format.

- [Validation Exception Handler](docs/handlers/validation.md).
- [Ajax Exception Handler](docs/handlers/ajax.md).
- [Json Exception Handler](docs/handlers/json.md).
- [Ajax Validation Exception Handler](docs/handlers/ajax-validation.md).
- [Json Validation Exception Handler](docs/handlers/json-validation.md).

Usage
-----

[](#usage)

### Default output formats

[](#default-output-formats)

If you want to use default output formats you can simply extend `Handler` class with Trammel's `BaseHandler` class in `app/Exception` folder.

```
// app/Exception/Handler.php
use Oguz\Trammel\Exception\BaseHandler;

class Handler extends BaseHandler
{
    // if class has render method, remove it
}
```

### Customizing handlers

[](#customizing-handlers)

if you don't want to use default behaviour of a handler, you can extend it. First let's create a new folder under `app/Exception` called `Handlers` to keep our custom exception handlers. This will make it more tidy and clean.

```
