PHPackages                             anton-am/phalcon-middleware - 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. anton-am/phalcon-middleware

ActiveLibrary[Framework](/categories/framework)

anton-am/phalcon-middleware
===========================

Middleware component for Phalcon.

4.0.0(3y ago)0819MITPHPPHP ^8.0

Since May 26Pushed 3y ago1 watchersCompare

[ Source](https://github.com/Anton-Am/phalcon-middleware)[ Packagist](https://packagist.org/packages/anton-am/phalcon-middleware)[ RSS](/packages/anton-am-phalcon-middleware/feed)WikiDiscussions 3.0.x Synced 2w ago

READMEChangelog (5)Dependencies (5)Versions (7)Used By (0)

AntonAm\\Phalcon\\Middleware
============================

[](#antonamphalconmiddleware)

Middleware component for Phalcon MVC controllers

[![Latest Stable Version](https://camo.githubusercontent.com/acad6bc680aace2ed85316a5c6edc04ca066f063d22c5f01e040555c170ffda0/68747470733a2f2f706f7365722e707567782e6f72672f616e746f6e2d616d2f7068616c636f6e2d6d6964646c65776172652f762f737461626c65)](https://packagist.org/packages/anton-am/phalcon-middleware)[![Total Downloads](https://camo.githubusercontent.com/c56c1e2f1590c5dffadeca37afacf29bb40181d737e39f6c073d449d15766f0e/68747470733a2f2f706f7365722e707567782e6f72672f616e746f6e2d616d2f7068616c636f6e2d6d6964646c65776172652f646f776e6c6f616473)](https://packagist.org/packages/anton-am/phalcon-middleware)[![Build Status](https://camo.githubusercontent.com/a3bfe72e159d7e578da782285f72731a83049ac3aba5055b5b4f52fa8826c874/68747470733a2f2f7472617669732d63692e6f72672f416e746f6e2d416d2f7068616c636f6e2d6d6964646c65776172652e7376673f6272616e63683d332e302e78)](https://travis-ci.org/Anton-Am/phalcon-middleware)

Installing
----------

[](#installing)

Install using Composer:

```
composer require anton-am/phalcon-middleware
```

or add to your composer.json

```
"anton-am/phalcon-middleware": "^3.0.0"
```

You'll need to add the event to the `dispatcher` DI service:

```
use AntonAm\Phalcon\Middleware\Event;
use Phalcon\Events\Manager;
use Phalcon\Mvc\Dispatcher;

// ...

$di->set(
    "dispatcher",
    function () use ($di) {
            $eventsManager = new Manager();

            //Attach a listener
            $eventsManager->attach(
                'dispatch:beforeExecuteRoute',
                new Event()
            );

            $dispatcher = new Dispatcher();
            $dispatcher->setEventsManager($eventsManager);
            return $dispatcher;
    },
    true
);
```

Now, you can create middleware classes:

```
namespace Modules\Frontend\Middlewares;

use Phalcon\Mvc\User\Plugin;
use AntonAm\Phalcon\Middleware\MiddlewareInterface;

/**
 * Class CSRF
 *
 * @package Modules\Frontend\Middlewares
 */
class CSRF extends Plugin implements MiddlewareInterface
{
    /**
     * @param array $params
     * @return bool
     */
    public function handle(array $params = []): bool
    {
        if (!$this->security->checkToken()) {
            $this->flashSession->error('Wrong CSRF');
            $this->response->redirect($this->request->getHTTPReferer(), true)->send();
            return false;
        }

        return true;
    }
```

Example
-------

[](#example)

### Controller

[](#controller)

```
class IndexController extends \Phalcon\Mvc\Controller
{
    /**
     * @Middleware("Modules\Frontend\Middlewares\MustBeLoggedIn")
     * @Middleware("Modules\Frontend\Middlewares\HasProject")
     * @Middleware("Modules\Frontend\Middlewares\MustBeInProjectAs", "Creator")
     * @Middleware("Modules\Frontend\Middlewares\CSRF")
     */
    public function indexAction()
    {
        // ...
    }
}
```

###  Health Score

31

—

LowBetter than 66% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity69

Established project with proven stability

 Bus Factor1

Top contributor holds 61.3% 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 ~224 days

Recently: every ~253 days

Total

7

Last Release

1244d ago

Major Versions

3.0.x-dev → 4.0.02023-02-02

PHP version history (2 changes)3.0.1PHP ~7.2

3.0.x-devPHP ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/af13af0d5187f733f6b7cb67a3dc40b5df3c7e1783d4aa5b7023d8ff4f2471c0?d=identicon)[Anton-Am](/maintainers/Anton-Am)

---

Top Contributors

[![SidRoberts](https://avatars.githubusercontent.com/u/1364214?v=4)](https://github.com/SidRoberts "SidRoberts (38 commits)")[![Anton-Am](https://avatars.githubusercontent.com/u/2063230?v=4)](https://github.com/Anton-Am "Anton-Am (12 commits)")[![thinhvoxuan](https://avatars.githubusercontent.com/u/2169723?v=4)](https://github.com/thinhvoxuan "thinhvoxuan (10 commits)")[![sergeyklay](https://avatars.githubusercontent.com/u/1256298?v=4)](https://github.com/sergeyklay "sergeyklay (2 commits)")

###  Code Quality

TestsCodeception

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/anton-am-phalcon-middleware/health.svg)

```
[![Health](https://phpackages.com/badges/anton-am-phalcon-middleware/health.svg)](https://phpackages.com/packages/anton-am-phalcon-middleware)
```

###  Alternatives

[laravel/socialite

Laravel wrapper around OAuth 1 &amp; OAuth 2 libraries.

5.7k104.3M836](/packages/laravel-socialite)[laravel/dusk

Laravel Dusk provides simple end-to-end testing and browser automation.

1.9k38.6M289](/packages/laravel-dusk)[nineinchnick/edatatables

Grid widget for the Yii Framework, wrapper for the DataTables jQuery plugin

173.2k](/packages/nineinchnick-edatatables)[link-cloud/fast-hyperf

LinkCloud Fast Hyperf

241.2k1](/packages/link-cloud-fast-hyperf)

PHPackages © 2026

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