PHPackages                             scherersoftware/cake-monitor - 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. [Logging &amp; Monitoring](/categories/logging)
4. /
5. scherersoftware/cake-monitor

ActiveCakephp-plugin[Logging &amp; Monitoring](/categories/logging)

scherersoftware/cake-monitor
============================

A simple config based monitoring plugin for CakePHP 3

v1.2.3(8y ago)025.7k—0%41MITPHPPHP &gt;=7.0

Since Mar 21Pushed 4y ago5 watchersCompare

[ Source](https://github.com/scherersoftware/cake-monitor)[ Packagist](https://packagist.org/packages/scherersoftware/cake-monitor)[ RSS](/packages/scherersoftware-cake-monitor/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (5)Dependencies (3)Versions (20)Used By (1)

CakePHP 3 cake-monitor
======================

[](#cakephp-3-cake-monitor)

[![License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.txt)

A simple config based monitoring plugin for CakePHP 3

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

[](#installation)

#### 1. require the plugin in your `composer.json`

[](#1-require-the-plugin-in-your-composerjson)

```
	"require": {
		...
		"scherersoftware/cake-monitor": "dev-master",
		...
	}

```

#### 2. Include the plugin using composer

[](#2-include-the-plugin-using-composer)

Open a terminal in your project-folder and run these commands:

```
$ composer update
$ composer install

```

#### 3. Load the plugin in your `config/bootstrap.php`

[](#3-load-the-plugin-in-your-configbootstrapphp)

```
Plugin::load('Monitor', ['bootstrap' => true, 'routes' => true]);

```

#### 4. Add configuration to your `config/app.php`

[](#4-add-configuration-to-your-configappphp)

```
	'CakeMonitor' => [
		'accessToken' => 'Header token (CAKEMONITORTOKEN) used for authentication',
		'projectName' => 'Name of the Cake Project',
		'serverDescription' => 'Identifier of the server - use of env() is recommended',
		'onSuccess' => function() {
			// callback function in case every check was successful
			die('Do things if everything is fine');
		}
	]

```

Note that the Header token (`accessToken`) is needed to grant access to the monitoring URL. Treat this token confidentially if your checking functions reveal classified information about your project. Use a suitable browser-plugin to modifiy your HTTP request header when you're calling the monitoring-URL.

Usage
-----

[](#usage)

By default this plugin triggers a status check on all MySQL tables of the project. This behavior can be overwritten in app.php.

### Define custom check-functions

[](#define-custom-check-functions)

Define custom check functions in your `app.php`. Checks can be defined as array fields with anonymous callback-functions here. The Array `'checks'` is merged with the one in `vendor/scherersoftware/cake-monitor/config/monitor.default.php` which contains the default database checking function.

You can use that function as reference to implement any checking function you want.

```
'CakeMonitor' => [
	'accessToken' => 'CAKEMONITORTOKEN',
	'projectName' => 'Name of the Cake Project',
	'serverDescription' => 'Identifier of the server - use of env() is recommended',
	'onSuccess' => function() {
		// callback function in case every check was successful
		die('Do things if everything is fine');
	},
	'checks' => [
		'FUNCTION_NAME' => [
			'callback' => function() {
				// your check function
				// see the default 'DATABASE' function for further information
				return true;
			}
		]
	]
]

```

If every checking function executes without any exceptions, the `'onSuccess'` callback function is called.

Call
----

[](#call)

Run the current checks and see their output anytime by calling the following URL: `http://YOUR_PROJECT_URL.tld/monitor`

Sentry Error Reporting
----------------------

[](#sentry-error-reporting)

The plugin contains functionality to hook into CakePHP's error reporting and send exceptions to the excellent error reporting service [Sentry](https://getsentry.com/).

### Configuration

[](#configuration)

The `CakeMonitor` configuration section in your `app.php` must contain a `Sentry` key

```
'Sentry' => [
	'enabled' => !Configure::read('debug'), # Boolean value to enable sentry error reporting
	'dsn' => '', # The DSN for the Sentry project. You find this on the Sentry Project Settings Page.
	'sanitizeFields' => [ # An array of fields, whose values will be removed before sending
						  # data to sentry. Be sure to include fields like session cookie names,
						  # sensitive environment variables and other private configuration.
		'password',
		'rememberuser',
		'auth_token',
		'api_token',
		'mysql_password',
		'email_password',
		'cookie'
	],
	// Optional callback for special filtering
	'sanitizeExtraCallback' => function (&$data) {
		if (isset($data['user']['id'])) {
			$data['user']['id'] = '*****';
		}
	},
	'extraDataCallback' => function() { # Extra data to send with every Sentry call. Works with SentryHandler::captureMessage() only!
        	if (!empty($_SESSION['Test'])) {
            		return $_SESSION['Test'];
        	}
    	}
]

```

In your `bootstrap.php` you have to tell CakePHP which ErrorHandler to use. Please find the following section:

```
/**
 * Register application error and exception handlers.
 */
$isCli = PHP_SAPI === 'cli';
if ($isCli) {
	(new ConsoleErrorHandler(Configure::read('Error')))->register();
} else {
	(new ErrorHandler(Configure::read('Error')))->register();
}

```

And modify it to look like this:

```
/**
 * Register application error and exception handlers.
 */
Plugin::load('Monitor', ['bootstrap' => true, 'routes' => true]); # important for loading and merging the configuration

$isCli = php_sapi_name() === 'cli';
if ($isCli) {
	(new \Monitor\Error\ConsoleErrorHandler(Configure::consume('Error')))->register();
} else {
	(new \Monitor\Error\ErrorHandler(Configure::consume('Error')))->register();
}

```

From now on, given that the configuration value `CakeMonitor.Sentry.enabled` is true, Errors and Exceptions are reported to Sentry without changing any of CakePHP's default ErrorHandler behavior.

If you're using **cake 3.3** and above, you have to use the ErrorHandlerMiddleware provided by this plugin to enable Sentry error tracking.

In you `Application.php` use the `Monitor\Middleware\ErrorHandlerMiddleware` instead of the `Cake\Error\Middleware\ErrorHandlerMiddleware`.

### Examples

[](#examples)

Loggin an exception into sentry:

```
$sentryHandler = new SentryHandler();
$sentryHandler->handle($exception);

```

Logging a message into sentry:

```
$sentryHandler = new SentryHandler();
$sentryHandler->captureMessage('Error within request.', null, [
	'extra' => [
		'result' => $result,
		'status' => $status
	]
]);

```

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity27

Limited adoption so far

Community20

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

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

Recently: every ~400 days

Total

16

Last Release

1567d ago

Major Versions

v1.2.3 → v2.0.0-rc12020-01-10

PHP version history (2 changes)v1.2.0PHP &gt;=7.0

v2.0.0-rc1PHP &gt;=7.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/7005ae518cf40495e5e8bbf91ae64379e5a853a62c2e35bcdc7ead11e6014ea2?d=identicon)[robertscherer](/maintainers/robertscherer)

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

---

Top Contributors

[![jonathan-neugber](https://avatars.githubusercontent.com/u/17924468?v=4)](https://github.com/jonathan-neugber "jonathan-neugber (5 commits)")[![robertschererc](https://avatars.githubusercontent.com/u/203977391?v=4)](https://github.com/robertschererc "robertschererc (4 commits)")[![felixkempf](https://avatars.githubusercontent.com/u/8512231?v=4)](https://github.com/felixkempf "felixkempf (2 commits)")[![cleptric](https://avatars.githubusercontent.com/u/6617432?v=4)](https://github.com/cleptric "cleptric (1 commits)")

### Embed Badge

![Health badge](/badges/scherersoftware-cake-monitor/health.svg)

```
[![Health](https://phpackages.com/badges/scherersoftware-cake-monitor/health.svg)](https://phpackages.com/packages/scherersoftware-cake-monitor)
```

###  Alternatives

[sentry/sentry-laravel

Laravel SDK for Sentry (https://sentry.io)

1.3k114.3M154](/packages/sentry-sentry-laravel)[sentry/sentry-symfony

Symfony integration for Sentry (http://getsentry.com)

73661.4M66](/packages/sentry-sentry-symfony)[sentry/sdk

This is a meta package of sentry/sentry. We recommend using sentry/sentry directly.

328134.8M151](/packages/sentry-sdk)[justbetter/magento2-sentry

Magento 2 Logger for Sentry

1851.5M3](/packages/justbetter-magento2-sentry)[stayallive/wp-sentry

A (unofficial) WordPress plugin to report PHP and JavaScript errors to Sentry.

379197.9k](/packages/stayallive-wp-sentry)[mito/yii2-sentry

Yii 2 extension for Sentry

92377.7k](/packages/mito-yii2-sentry)

PHPackages © 2026

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