PHPackages                             sageit/phalcon-exception-handler - 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. [Framework](/categories/framework)
4. /
5. sageit/phalcon-exception-handler

ActiveLibrary[Framework](/categories/framework)

sageit/phalcon-exception-handler
================================

Sage IT Component for Phalcon - Annotations Parser for annotation routes

v1.03(3y ago)0141MITPHPPHP &gt;=7.0

Since Dec 28Pushed 3y agoCompare

[ Source](https://github.com/SageITSolutions/phalcon-exception-handler)[ Packagist](https://packagist.org/packages/sageit/phalcon-exception-handler)[ RSS](/packages/sageit-phalcon-exception-handler/feed)WikiDiscussions main Synced 1mo ago

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

 [ ![Logo](.readme/logo.png) ](https://github.com/SageITSolutions/phalcon-exception-handler)Phalcon Exception Handler
=========================

[](#phalcon-exception-handler)

[![Latest Stable Version](https://camo.githubusercontent.com/65ea01dd4cf9c2a1a2089f6350c79381a03ea9edba5e28593c3c838c609c8416/687474703a2f2f706f7365722e707567782e6f72672f7361676569742f7068616c636f6e2d657863657074696f6e2d68616e646c65722f763f7374796c653d706c6173746963)](https://packagist.org/packages/sageit/phalcon-exception-handler)[![Total Downloads](https://camo.githubusercontent.com/1a1a34c494754c9892139cef14939a224d755eb90ac9944a01cf6a86bd73b1ac/687474703a2f2f706f7365722e707567782e6f72672f7361676569742f7068616c636f6e2d657863657074696f6e2d68616e646c65722f646f776e6c6f6164733f7374796c653d706c6173746963)](https://packagist.org/packages/sageit/phalcon-exception-handler)[![License](https://camo.githubusercontent.com/ec561314f730764b6c4aa9796b3f7c44e3a6c12c0fae21f698f531f1c21499b3/687474703a2f2f706f7365722e707567782e6f72672f7361676569742f7068616c636f6e2d657863657074696f6e2d68616e646c65722f6c6963656e73653f7374796c653d706c6173746963)](https://packagist.org/packages/sageit/phalcon-exception-handler)[![PHP Version Require](https://camo.githubusercontent.com/aaa0a8aefd795981450eb3f903dbd669e5a0d9bd783e8e70c9cce05849180096/687474703a2f2f706f7365722e707567782e6f72672f7361676569742f7068616c636f6e2d657863657074696f6e2d68616e646c65722f726571756972652f7068703f7374796c653d706c6173746963)](https://packagist.org/packages/sageit/phalcon-exception-handler)[![Phalcon Version](https://camo.githubusercontent.com/60e460c1f85f7a97b3243af763f24ac4ac42c16013343107fb65d04ff005d3b2/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646570656e64656e63792d762f7361676569742f7068616c636f6e2d657863657074696f6e2d68616e646c65722f6578742d7068616c636f6e3f6c6162656c3d5068616c636f6e266c6f676f3d5068616c636f6e25323056657273696f6e267374796c653d706c6173746963)](https://packagist.org/packages/sageit/phalcon-exception-handler)

 Adds Preset throwable exceptions along with a built in handler with included logging.

**[Explore the docs »](https://github.com/SageITSolutions/phalcon-exception-handler)**

**[Report Bug](https://github.com/SageITSolutions/phalcon-exception-handler/issues)** · **[Request Feature](https://github.com/SageITSolutions/phalcon-exception-handler/issues)**

Table of Contents
-----------------

[](#table-of-contents)

- [Table of Contents](#table-of-contents)
- [About The Project](#about-the-project)
    - [Built With](#built-with)
- [Installation](#installation)
- [Usage](#usage)
    - [Full Application](#full-application)
    - [Micro Application](#micro-application)
    - [Custom Exceptions](#custom-exceptions)
    - [Additional Methods](#additional-methods)
- [Roadmap](#roadmap)
- [Contributing](#contributing)
- [License](#license)
- [Contact](#contact)

About The Project
-----------------

[](#about-the-project)

### Built With

[](#built-with)

- [vscode](https://code.visualstudio.com/)
- [php 8.1.1](https://www.php.net/releases/8_1_1.php)
- [Phalcon 5](https://phalcon.io/en-us) (Micro Framework)

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

[](#installation)

**Git:**

```
git clone https://github.com/SageITSolutions/phalcon-exception-handler.git
```

**Composer:**

```
composer require sageit/phalcon-exception-handler
```

Usage
-----

[](#usage)

This project consists of an included Exception Handler which is supported by both Full suite Phalcon Applications and Micro Apps. The intent is to integrate logging and presentation to generic exceptions.

***This should not be used in lieu of `Phalcon\Support\Debug` functionality. The exception-handler is intended for production handling of known events***

### Full Application

[](#full-application)

```
new Phalcon\Exception\Handler(true,'Error');
```

*This action would instantiation a new Exception Handler which is set globally (`true`) as the exception\_handler. `'Error'` Can be replaced with any CSS Class used by a flash service for displaying exceptions.*

**if Logger is present**, and log level is greater than or equal to the `LOG_LEVEL` defined in the exception, an event will be logged according to the level specified. This is useful for auditing failed authentication attempts.

**if Flash is present**, a flash alert will be displayed when an Exception is thrown. Exceptions not included in this lib will be automagically converted to a generic "Unknown Exception".

**if Flash is not present**, a simple echo with `Exception encountered: {error message}` will return.

### Micro Application

[](#micro-application)

Add the following within the Micro class

```
$this->error(function ($exception) {
  $handler = new \Phalcon\Exception\Handler(false);
  $this
    ->response
    ->setStatusCode($code)
    ->setJsonContent($handler->getJSON($exception))
    ->send();
  die;
});
```

*The same logging action of the Full Application takes place if a `Logger` Service is present in dependancy injection*

### Custom Exceptions

[](#custom-exceptions)

You are not limited to the provided Exceptions. Any custom Exception can be created by extending `\Phalcon\Exception\Exception`

```
class MyCustomException extends Phalcon\Exception\Exception {
    protected const ERROR_MESSAGE = 'I\'ve created a new custom Exceptions #reasons';
    protected const ERROR_CODE    = 401;
    protected const LOG_MESSAGE = 'My custom exception was activated';
    protected const LOG_LEVEL = 'alert';
```

*`LOG_LEVEL` Corresponds to the levels utilized by `\Phalcon\Logger\Logger`*

**Log Levels**

1. Emergency
2. Critical
3. Alert
4. Error
5. Warning
6. Notice
7. Info
8. Debug
9. Custom

### Additional Methods

[](#additional-methods)

**setDisplay**

*the CSS displayClass used by flash can be altered before an exception is thrown so the default exception handler can apply the correct styling*

```
$handler->setDisplay('Notification');
```

**display**

*if global error catching is not in place, and you need to utilize the flash display service with a custom class, this can bbe called directly*

```
$handler->display($exception,'Notification');
```

*The exception provided can be any Throwable \\Exception*

**log**

*if there is a need to log an exception without displaying it, this can be called directly. This will do nothing if no `Logger` Service is present*

```
$handler->log($exception,'Notification');
```

**getJSON**

\_as demonstrated in the MicroApp the method `getJSON` returns a named array with the elements of the exception.

```
$handler->getJSON($exception);
```

`result`

```
[
  'code' => 500,  //$this->getCode()
  'status' => 'error',
  'message' => 'Exception Encountered' //$this->getMessage()
]
```

**convertException**

*this **static** method is called within several other methds but can be used externally to transpose a generic exception into the `\Phalcon\Exception\Exception` utilized by this handler*

```
\Phalcon\Exception\Handler::convertException($exception);
```

*there is no returned value, as this action is completed as a variable reference*

Roadmap
-------

[](#roadmap)

See the [open issues](/issues) for a list of proposed features (and known issues).

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

[](#contributing)

Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are **greatly appreciated**.

1. Fork the Project
2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`)
3. Commit your Changes (`git commit -m 'Add some AmazingFeature'`)
4. Push to the Branch (`git push origin feature/AmazingFeature`)
5. Open a Pull Request

License
-------

[](#license)

Distributed under the MIT License. See `LICENSE` for more information.

Contact
-------

[](#contact)

Sage IT Solutions - [Email](mailto:daniel.davis@sageitsolutions.net)

Project Link:

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity45

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

Total

6

Last Release

1229d ago

Major Versions

v0.02 → v1.002022-12-30

### Community

Maintainers

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

---

Top Contributors

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

---

Tags

frameworkmicrophalconannotation

### Embed Badge

![Health badge](/badges/sageit-phalcon-exception-handler/health.svg)

```
[![Health](https://phpackages.com/badges/sageit-phalcon-exception-handler/health.svg)](https://phpackages.com/packages/sageit-phalcon-exception-handler)
```

###  Alternatives

[slim/slim

Slim is a PHP micro framework that helps you quickly write simple yet powerful web applications and APIs

12.2k49.9M1.3k](/packages/slim-slim)[phprest/phprest

PHP Rest Framework.

3049.3k](/packages/phprest-phprest)

PHPackages © 2026

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