PHPackages                             phillipsharring/handlr-backend - 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. phillipsharring/handlr-backend

ActiveLibrary[Framework](/categories/framework)

phillipsharring/handlr-backend
==============================

Handlr is a lightweight PHP middleware style framework.

v0.5.0(2mo ago)00MITPHPPHP &gt;=8.4

Since Mar 23Pushed today1 watchersCompare

[ Source](https://github.com/phillipsharring/handlr-backend)[ Packagist](https://packagist.org/packages/phillipsharring/handlr-backend)[ Docs](https://github.com/phillipsharring/handlr-framework)[ RSS](/packages/phillipsharring-handlr-backend/feed)WikiDiscussions main Synced today

READMEChangelogDependencies (10)Versions (7)Used By (0)

Handlr Backend
==============

[](#handlr-backend)

[![Handlr](handlr.png)](handlr.png)

A lightweight PHP middleware-style framework built around the **Pipe + Handler** pattern.

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

[](#installation)

```
composer require phillipsharring/handlr-backend
```

For a ready-to-go project structure, scaffold a full app with `composer create-project phillipsharring/handlr-app` (see the [app skeleton](https://github.com/phillipsharring/handlr-mono/tree/main/packages/app)).

Architecture
------------

[](#architecture)

Handlr separates HTTP concerns from business logic:

- **Pipe** - middleware that sees `Request`/`Response`. Handles auth, validation, CORS, CSRF, etc.
- **Handler** - pure business logic. Receives typed `HandlerInput`, returns `HandlerResult`. No HTTP awareness.
- **HandlerInput** - validated input object. Used identically for HTTP requests and event listeners.
- **HandlerResult** - structured result: `ok($data)` or `fail($errors)`.

Below the Pipe layer, everything is Handler/HandlerInput - whether it came from HTTP or an event dispatch.

What's Included
---------------

[](#whats-included)

### Core

[](#core)

- `Request` / `Response` - HTTP abstractions
- `Router` / `RouteGroup` - routing with middleware pipelines and `{param:type}` constraints
- `Kernel` - request dispatcher
- `Container` - dependency injection with singleton/bind patterns
- `EventManager` - synchronous pub/sub

### Database

[](#database)

- `Db` - lazy PDO wrapper with transaction support
- `NullDb` - throws on query (for simulation/test modes)
- `Table` - CRUD base class (insert, update, delete, findWhere, findById, paginate)
- `Record` - domain object base class with UUID support
- `Query` - read-only query base class (rows, row, scalar, count, column)
- `MigrationRunner` / `Seeder` - database lifecycle

### Auth &amp; Security

[](#auth--security)

- `AuthContext` - request-scoped user identity holder
- `AuthorizationService` - RBAC permission checking via injectable `PermissionsProviderInterface`
- `AuthSubject` / `AuthorizedUser` - authenticated user contract and implementation
- Session-based auth pipes: `StartSessionPipe`, `SessionAuthPipe`, `RequireAuthPipe`
- Permission guard pipes: `RequirePermissionPipe`, `RequireAllPermissionsPipe`
- `CsrfService` - token generation, validation, and rotation
- CSRF pipes: `EnsureCsrfTokenPipe`, `VerifyCsrfTokenPipe`
- `CorsPipe` / `VerifyOriginPipe` - origin validation

### Validation

[](#validation)

- `Validator` with rule strings (`'string|min:3'`, `'int|min:1,max:50'`)
- 20+ built-in rules, 9 sanitizers
- `ValidatedInputFactory` - pipe-to-handler validation bridge

### API

[](#api)

- `Presenter` - response envelope builder (success, error, validation error formatting)

### Utilities

[](#utilities)

- `SortableList` trait - column sort extraction and meta generation
- `TreeSortKeyService` - hierarchical sort key computation with locking
- `Logger` - file-based PSR-3 logger

### Code Generation

[](#code-generation)

- `make:migration`, `make:seeder`, `make:record`, `make:table`, `make:handler`, `make:pipe`, `make:scaffold`

Standard Pipes
--------------

[](#standard-pipes)

PipePurpose`ErrorPipe`Global exception handler`LogPipe`Request logging`JsonPipe`JSON body parsing`ViewPipe`Template rendering`StartSessionPipe`PHP session initialization`SessionAuthPipe`Session-to-AuthContext bridge`RequireAuthPipe`401 if not authenticated`RequirePermissionPipe`403 if missing any listed permission`RequireAllPermissionsPipe`403 if missing all listed permissions`CorsPipe`Same-origin CORS headers`VerifyOriginPipe`Origin/Referer validation for writes`EnsureCsrfTokenPipe`Token initialization + cookie transport`VerifyCsrfTokenPipe`Token validation + rotationQuick Example
-------------

[](#quick-example)

```
// routes.php
$router->group('/api', [CorsPipe::class, VerifyOriginPipe::class])
    ->through([StartSessionPipe::class, SessionAuthPipe::class, EnsureCsrfTokenPipe::class, VerifyCsrfTokenPipe::class])
        ->get('/auth/me', [GetAuthStatus::class])
        ->through([RequireAuthPipe::class])
            ->get('/items', [GetItemsList::class])
            ->post('/items', [PostCreateItem::class])
        ->end()
    ->end()
->end();
```

Requirements
------------

[](#requirements)

- PHP &gt;= 8.4
- PDO extension

License
-------

[](#license)

MIT

###  Health Score

38

—

LowBetter than 83% of packages

Maintenance93

Actively maintained with recent releases

Popularity0

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity46

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

Total

6

Last Release

76d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/11220?v=4)[Phil Harrington](/maintainers/phillipsharring)[@phillipsharring](https://github.com/phillipsharring)

---

Top Contributors

[![phillipsharring](https://avatars.githubusercontent.com/u/11220?v=4)](https://github.com/phillipsharring "phillipsharring (143 commits)")

---

Tags

frameworkhandlr

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/phillipsharring-handlr-backend/health.svg)

```
[![Health](https://phpackages.com/badges/phillipsharring-handlr-backend/health.svg)](https://phpackages.com/packages/phillipsharring-handlr-backend)
```

###  Alternatives

[laravel/framework

The Laravel Framework.

34.8k532.1M19.4k](/packages/laravel-framework)[tempest/framework

The PHP framework that gets out of your way.

2.2k31.1k12](/packages/tempest-framework)[matomo/matomo

Matomo is the leading Free/Libre open analytics platform

21.6k38.2k](/packages/matomo-matomo)[shopware/platform

The Shopware e-commerce core

3.4k1.5M3](/packages/shopware-platform)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

585.4M514](/packages/shopware-core)[drupal/core

Drupal is an open source content management platform powering millions of websites and applications.

19564.8M1.6k](/packages/drupal-core)

PHPackages © 2026

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