PHPackages                             tatter/handlers - 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. tatter/handlers

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

tatter/handlers
===============

Handler discovery and management, for CodeIgniter 4

v3.0.0(3y ago)311.6k↓50%1[1 PRs](https://github.com/tattersoftware/codeigniter4-handlers/pulls)5MITPHPPHP ^7.4 || ^8.0

Since Aug 9Pushed 2y ago1 watchersCompare

[ Source](https://github.com/tattersoftware/codeigniter4-handlers)[ Packagist](https://packagist.org/packages/tatter/handlers)[ Docs](https://github.com/tattersoftware/codeigniter4-handlers)[ Fund](https://paypal.me/tatter)[ GitHub Sponsors](https://github.com/tattersoftware)[ RSS](/packages/tatter-handlers/feed)WikiDiscussions develop Synced 1mo ago

READMEChangelog (10)Dependencies (2)Versions (19)Used By (5)

Tatter\\Handlers
================

[](#tatterhandlers)

Handler discovery and management, for CodeIgniter 4

[![](https://github.com/tattersoftware/codeigniter4-handlers/workflows/PHPUnit/badge.svg)](https://github.com/tattersoftware/codeigniter4-handlers/actions/workflows/test.yml)[![](https://github.com/tattersoftware/codeigniter4-handlers/workflows/PHPStan/badge.svg)](https://github.com/tattersoftware/codeigniter4-handlers/actions/workflows/analyze.yml)[![](https://github.com/tattersoftware/codeigniter4-handlers/workflows/Deptrac/badge.svg)](https://github.com/tattersoftware/codeigniter4-handlers/actions/workflows/inspect.yml)[![Coverage Status](https://camo.githubusercontent.com/df8c3ed9884bca7b947cf65bddfea06f13fba6aa83af335f008dd07bbd99bca2/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f746174746572736f6674776172652f636f646569676e69746572342d68616e646c6572732f62616467652e7376673f6272616e63683d646576656c6f70)](https://coveralls.io/github/tattersoftware/codeigniter4-handlers?branch=develop)

Quick Start
-----------

[](#quick-start)

1. Install with Composer: `> composer require tatter/handlers`
2. Create a Factory to identify your handlers
3. Discover classes from any namespace: `$widgets = WidgetFactory::findAll();`

Features
--------

[](#features)

**Handlers** allows developers to define and discover classes of predetermined types across all namespaces; it is essentially a database-free "model" for classes.

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

[](#installation)

Install easily via Composer to take advantage of CodeIgniter 4's autoloading capabilities and always be up-to-date:

```
composer require tatter/handlers
```

Or, install manually by downloading the source files and adding the directory to **app/Config/Autoload.php**.

Configuration (optional)
------------------------

[](#configuration-optional)

The library's default behavior can be altered by extending its config file. Copy **examples/Handlers.php** to **app/Config/** and follow the instructions in the comments. If no config file is found in **app/Config** the library will use its own.

Usage
-----

[](#usage)

**Handlers** uses relative paths to discover files that contain handler classes. Create a new folder in your project or module with an appropriate name for your implementation, e.g. **app/Widgets/** or **src/Reports**.

### Compatibility

[](#compatibility)

In order for them be discovered as handlers your classes need to have a consistent class or interface type and supply a unique ID via the class constant `HANDLER_ID`.

**Handlers** will resolve class extensions by using this handler ID, so if you want your app to "replace" a handler from another namespace then simply extend the original class and leave the `HANDLER_ID` constant the same.

### Factories

[](#factories)

Once your handler classes are created you will need a Factory that provides the lookup path and expected class or interface to identify the handlers. Create the new class extending `BaseFactory`:

```
