PHPackages                             phalcon/incubator-events - 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. phalcon/incubator-events

ActiveLibrary[Framework](/categories/framework)

phalcon/incubator-events
========================

Phalcon Incubator Events

v1.0.1(4y ago)4505[2 PRs](https://github.com/phalcon/incubator-events/pulls)BSD-3-ClausePHPPHP &gt;=7.2

Since Jun 28Pushed 3y ago5 watchersCompare

[ Source](https://github.com/phalcon/incubator-events)[ Packagist](https://packagist.org/packages/phalcon/incubator-events)[ Docs](https://phalcon.io)[ GitHub Sponsors](https://github.com/phalcon)[ Fund](https://opencollective.com/phalcon)[ RSS](/packages/phalcon-incubator-events/feed)WikiDiscussions master Synced today

READMEChangelog (2)Dependencies (6)Versions (6)Used By (0)

Phalcon\\Incubator\\Events
==========================

[](#phalconincubatorevents)

Usage examples of the features is here:

Manager
-------

[](#manager)

### Classic event handling

[](#classic-event-handling)

Classic event handling requires one class with a bunch of methods named equal to event name.

And multiple `$eventsManager->attach()` calls if you use more than one handler for single event:

```
class DispatchEventsHandler
{
    public function beforeCallActionMethod(
        Phalcon\Events\EventInterface $event,
        Phalcon\Dispatcher\DispatcherInterface $dispatcher
    ): void {
        //do some stuff
    }

    public function beforeDoSomeMistakes(
        Phalcon\Events\EventInterface $event,
        Phalcon\Dispatcher\DispatcherInterface $dispatcher
    ): void {
        //do some right stuff
    }
}

class DispatchEventsHandlerTwo
{
    public function beforeCallActionMethod(
        Phalcon\Events\EventInterface $event,
        Phalcon\Dispatcher\DispatcherInterface $dispatcher
    ): void {
        //do another stuff in same event
    }
}

$eventsManager = new Phalcon\Events\Manager();
$eventsManager->attach('dispatch:beforeCallActionMethod',new DispatchEventsHandler(), 100);
$eventsManager->attach('dispatch:beforeCallActionMethod',new DispatchEventsHandlerTwo(), 101);
$eventsManager->attach('dispatch:beforeDoSomeMistakes',new DispatchEventsHandler());
//or global way
$eventsManager->attach('dispatch',new DispatchEventsHandler(), 100);
$eventsManager->attach('dispatch',new DispatchEventsHandlerTwo(), 101);
```

### Featured event handling

[](#featured-event-handling)

This manager version provides a feature of single responsible event handlers via configs, using `__invoke`.

Create your handler class:

```
class BeforeCallActionMethod
{
    public function __invoke(
        Phalcon\Events\EventInterface $event,
        Phalcon\Dispatcher\DispatcherInterface $dispatcher
    ): void {
        //do some stuff
    }
}
```

Define configuration in config file:

```
$config = new Phalcon\Config([
  'handlers' => [
      'dispatch:beforeCallActionMethod' => BeforeCallActionMethod::class,
  ],
]);
```

Define `Phalcon\Incubator\Events\Manager` in container as eventsManager service using config of handlers:

```
$handlers = $config->get('handlers')->toArray();

$eventsManager = new Phalcon\Incubator\Events\Manager();
$eventsManager->loadHandlers($handlers);
```

There are multiple ways to define configs of handlers:

Flat classname usage, if your handler is invokable:

```
$flat = new Phalcon\Config([
    'handlers' => [
        'dispatch:beforeCallActionMethod' => BeforeCallActionMethod::class,
    ],
]);
```

Same, but more informative and with optional priority:

```
$verbose = new Phalcon\Config([
    'handlers' => [
        'dispatch:beforeCallActionMethod' => [
            'class' => BeforeCallActionMethod::class,
            'priority' => 100, //optional
        ],
    ],
]);
```

Using callable constructions:

```
$callable = new Phalcon\Config([
    'handlers' => [
        //you can use any other public method name instead of method, for example run()
        'dispatch:beforeCallActionMethod' => [new BeforeCallActionMethod(), 'run'],
        //or
        'dispatch:beforeCallActionMethod' => [BeforeCallActionMethod::class, 'staticRun'],
    ],
]);
```

Grouping more than one handler for one event:

```
$grouped = new Phalcon\Config([
    'handlers' => [
        'dispatch:beforeCallActionMethod' => [
            BeforeCallActionMethod::class,
            BeforeCallActionMethodAnother::class,
            BeforeCallActionMethodThird::class,
        ],
    ],
]);

$groupedVerbose = new Phalcon\Config([
    'handlers' => [
        'dispatch:beforeCallActionMethod' => [
            [
                'class' => BeforeCallActionMethod::class,
                'priority' => 100, //optional
            ],
            [
                'class' => BeforeCallActionMethodAnother::class,
                'priority' => 101, //optional
            ],
            [
                'class' => BeforeCallActionMethodThird::class,
                'priority' => 101, //optional
            ],
        ],
    ],
]);
```

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 54.5% 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 ~155 days

Total

4

Last Release

1676d ago

Major Versions

v1.0.1 → v2.x-dev2021-10-06

### Community

Maintainers

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

---

Top Contributors

[![Jeckerson](https://avatars.githubusercontent.com/u/3289702?v=4)](https://github.com/Jeckerson "Jeckerson (6 commits)")[![BeMySlaveDarlin](https://avatars.githubusercontent.com/u/10584911?v=4)](https://github.com/BeMySlaveDarlin "BeMySlaveDarlin (3 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (2 commits)")

---

Tags

frameworkeventsmanagerphalconincubator

###  Code Quality

TestsCodeception

Static AnalysisPHPStan, Psalm

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/phalcon-incubator-events/health.svg)

```
[![Health](https://phpackages.com/badges/phalcon-incubator-events/health.svg)](https://phpackages.com/packages/phalcon-incubator-events)
```

###  Alternatives

[phalcon/incubator

Adapters, prototypes or functionality that can be potentially incorporated to the C-framework.

7222.9M81](/packages/phalcon-incubator)[phalcon/devtools

This tools provide you useful scripts to generate code helping to develop faster and easy applications that use with Phalcon framework.

1.3k2.0M54](/packages/phalcon-devtools)[pestphp/pest-plugin

The Pest plugin manager

4458.2M107](/packages/pestphp-pest-plugin)[phalcon/incubator-mailer

Phalcon Incubator Mailer Adapters

1318.1k2](/packages/phalcon-incubator-mailer)

PHPackages © 2026

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