PHPackages                             apirelio/cakephp - 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. apirelio/cakephp

ActiveLibrary

apirelio/cakephp
================

Fail-safe CakePHP middleware for Apirelio customer integration analytics.

v1.0.0(today)02↑2900%MITPHPPHP ^8.2CI passing

Since Aug 28Pushed todayCompare

[ Source](https://github.com/pryznar/apirelio-cakephp)[ Packagist](https://packagist.org/packages/apirelio/cakephp)[ RSS](/packages/apirelio-cakephp/feed)WikiDiscussions main Synced today

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

Apirelio CakePHP SDK
====================

[](#apirelio-cakephp-sdk)

[Documentation](https://apirelio.com/docs/php/cakephp) · [Live demo](https://apirelio.com/demo?framework=cakephp) · [Packagist](https://packagist.org/packages/apirelio/cakephp) · [Apirelio](https://apirelio.com)

[![Packagist Version](https://camo.githubusercontent.com/c2b916f33c570c00051d9f83550b53d56c9f5efaf4d285cf203d9971ed27045c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f61706972656c696f2f63616b657068702e737667)](https://packagist.org/packages/apirelio/cakephp)[![Tests](https://github.com/pryznar/apirelio-cakephp/actions/workflows/tests.yml/badge.svg)](https://github.com/pryznar/apirelio-cakephp/actions/workflows/tests.yml)

Customer-aware API monitoring middleware for CakePHP 4.5 and 5.x. It captures route-level operational telemetry without request or response payloads and delegates the shared event contract, privacy filtering and delivery to `apirelio/php-core`.

[![Apirelio customer-level API dashboard](https://raw.githubusercontent.com/pryznar/apirelio-app/main/apps/frontend/public/img/apirelio-live-demo-dashboard.jpg)](https://apirelio.com/demo?framework=cakephp)

**[See the live customer-impact demo →](https://apirelio.com/demo?framework=cakephp)**

Install in 30 seconds
---------------------

[](#install-in-30-seconds)

```
composer require apirelio/cakephp:^1.0
```

```
// src/Application.php
use Apirelio\CakePHP\ApirelioMiddleware;
use Apirelio\CakePHP\Config as ApirelioConfig;
use Cake\Error\Middleware\ErrorHandlerMiddleware;
use Cake\Http\MiddlewareQueue;
use Cake\Routing\Middleware\RoutingMiddleware;

public function middleware(MiddlewareQueue $middlewareQueue): MiddlewareQueue
{
    $middlewareQueue
        ->add(new ErrorHandlerMiddleware())
        ->add(new RoutingMiddleware($this))
        ->add(new ApirelioMiddleware(new ApirelioConfig(
            apiKey: (string) env('APIRELIO_API_KEY'),
            service: 'billing-api',
            environment: (string) env('APP_ENV', 'production'),
            release: env('APP_RELEASE') ?: null,
            paths: ['/api/*'],
            bufferPath: LOGS.'apirelio-events.ndjson',
        )));

    return $middlewareQueue;
}
```

Put Apirelio after `RoutingMiddleware` so it receives CakePHP's `_matchedRoute` template. Keep `ErrorHandlerMiddleware` before it so CakePHP can still render the original exception after Apirelio records its class.

Identify the customer
---------------------

[](#identify-the-customer)

```
use Apirelio\Core\Data\ApirelioApplication;
use Apirelio\Core\Data\ApirelioCustomer;

$middleware = new ApirelioMiddleware(
    config: $config,
    customerResolver: static function ($request): ?ApirelioCustomer {
        $account = $request->getAttribute('identity')?->getOriginalData();

        return $account === null ? null : new ApirelioCustomer(
            id: (string) $account->id,
            name: $account->name,
            plan: $account->plan,
        );
    },
    applicationResolver: static fn ($request) => new ApirelioApplication(
        id: (string) $request->getAttribute('apiClient')->id,
    ),
);
```

Add safe request context
------------------------

[](#add-safe-request-context)

```
use Apirelio\CakePHP\RequestContext;

$context = $this->getRequest()->getAttribute(RequestContext::ATTRIBUTE);
$context?->addMetadata(['region' => 'eu-central']);
$context?->setErrorCode('PAYMENT_REQUIRED');
```

Only scalar metadata keys listed in `metadataKeys` are retained. Sensitive-looking keys are always rejected. Request bodies, response bodies, query strings, credentials, cookies, client IPs and exception messages are never captured.

Example application
-------------------

[](#example-application)

The [`example`](example) directory contains the complete middleware and controller snippets for a CakePHP API. Connect it to a project and then open the [live Apirelio demo](https://apirelio.com/demo?framework=cakephp) to see the resulting customer-level workflow.

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

[](#requirements)

- PHP 8.2+
- CakePHP 4.5 or 5.x
- ext-curl and ext-mbstring

License
-------

[](#license)

MIT

###  Health Score

42

—

FairBetter than 88% of packages

Maintenance100

Actively maintained with recent releases

Popularity3

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity49

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

Total

4

Last Release

0d ago

Major Versions

v0.1.2 → v1.0.02026-08-28

### Community

Maintainers

![](https://www.gravatar.com/avatar/461b0a594590cb170c4544f10538e6fef5a98320c4f584188fc1a34c10143545?d=identicon)[pryznar](/maintainers/pryznar)

---

Top Contributors

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

---

Tags

api-monitoringb2b-saascakephpcustomer-analyticsobservabilityphppsr-15cakephpobservabilityAPI monitoringcustomer-analytics

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/apirelio-cakephp/health.svg)

```
[![Health](https://phpackages.com/badges/apirelio-cakephp/health.svg)](https://phpackages.com/packages/apirelio-cakephp)
```

###  Alternatives

[cakephp/cakephp

The CakePHP framework

8.9k20.0M1.9k](/packages/cakephp-cakephp)[cakephp/authentication

Authentication plugin for CakePHP

1214.3M121](/packages/cakephp-authentication)[typo3/cms

TYPO3 CMS is a free open source Content Management Framework initially created by Kasper Skaarhoj and licensed under GNU/GPL.

1.2k1.9M122](/packages/typo3-cms)[typo3/cms-core

TYPO3 CMS Core

3313.6M5.7k](/packages/typo3-cms-core)[cakephp/authorization

Authorization abstraction layer plugin for CakePHP

742.6M55](/packages/cakephp-authorization)[typo3/cms-adminpanel

TYPO3 CMS Admin Panel - The Admin Panel displays information about your site in the frontend and contains a range of metrics including debug and caching information.

115.8M71](/packages/typo3-cms-adminpanel)

PHPackages © 2026

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