PHPackages                             mirko-pagliai/cakephp-essentials - 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. mirko-pagliai/cakephp-essentials

ActiveCakephp-plugin

mirko-pagliai/cakephp-essentials
================================

cakephp-essentials

1.0.27(1mo ago)05.5k↓73.2%MITPHPPHP &gt;=8.4CI passing

Since Jun 27Pushed 1mo agoCompare

[ Source](https://github.com/mirko-pagliai/cakephp-essentials)[ Packagist](https://packagist.org/packages/mirko-pagliai/cakephp-essentials)[ Docs](https://github.com/mirko-pagliai/cakephp-essentials)[ RSS](/packages/mirko-pagliai-cakephp-essentials/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (11)Versions (30)Used By (0)

cakephp-essentials
==================

[](#cakephp-essentials)

[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.txt)[![CI](https://github.com/mirko-pagliai/cakephp-essentials/actions/workflows/ci.yml/badge.svg)](https://github.com/mirko-pagliai/cakephp-essentials/actions/workflows/ci.yml)[![codecov](https://camo.githubusercontent.com/39612ffec22b4576fee6a9b0d15f9a1f1795f89afc58c0915326ae8150cd8300/68747470733a2f2f636f6465636f762e696f2f67682f6d69726b6f2d7061676c6961692f63616b657068702d657373656e7469616c732f6272616e63682f6d61737465722f67726170682f62616467652e7376673f746f6b656e3d45473471594e5a726769)](https://codecov.io/gh/mirko-pagliai/cakephp-essentials)[![Codacy Badge](https://camo.githubusercontent.com/60041c6b46adb99d64acae3f2969ee59ff783ac6a7006130ea004c606567a643/68747470733a2f2f6170702e636f646163792e636f6d2f70726f6a6563742f62616467652f47726164652f3565353337636531646130363435303838356338343137393966623433633661)](https://app.codacy.com/gh/mirko-pagliai/cakephp-essentials/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade)

Various classes and useful utilities for various CakePHP projects.

- [Global functions](#global-functions)
- [Request detectors](#request-detectors)
- [Extends the View](#extends-the-view)
- [Using Tooltips and Popovers](#using-tooltips-and-popovers)
- [How to use Bake templates](#how-to-use-bake-templates)

Global functions
----------------

[](#global-functions)

### rtr()

[](#rtr)

`rtr()` is an acronym for "relative to root."

Returns a path relative to `ROOT`, useful for some output (e.g., commands).

For example:

```
rtr(ROOT . 'webroot/assets')
```

returns `webroot/assets`.

The function preserves any trailing slashes and throws exceptions for invalid paths (e.g. not relative to `ROOT` or not absolute).

### toDate() and toDateTime()

[](#todate-and-todatetime)

These two functions ensure they always return a valid `Date` or `DateTime` instance.

They are useful when a variable may already be a valid instance or an argument to create an instance and allow you to avoid this:

```
if (!$dateTime instanceof DateTime) {
    $dateTime = new DateTime($dateTime);
}

//or

$date = $date instanceof Date ? $date : new Date($date);
```

simply by doing this:

```
$dateTime = toDateTime($dateTime);

//or

$date = toDate($date);
```

Request detectors
-----------------

[](#request-detectors)

This plugin provides several very useful [request detectors](https://book.cakephp.org/5.x/controllers/request-response.html#checking-request-conditions).

### is('action') detector

[](#isaction-detector)

Checks if `$action` matches the current action.

The `$action` argument can be a string or an array of strings. In the second case, it is enough that the action matches one of those.

Example:

```
$this->getRequest()->is('action', 'delete')
```

returns `true` if the current action is `delete`, otherwise `false`.

Example:

```
$this->getRequest()->isAction('action', 'edit', 'delete')
```

returns `true` if the current action is `edit` or `delete`, otherwise `false`.

### Other "action detectors": is('add'), is('edit'), is('view'), is('index'), is('delete')

[](#other-action-detectors-isadd-isedit-isview-isindex-isdelete)

These are quick aliases for `is('action')` detectors.

Example:

```
$this->getRequest()->is('delete')
```

returns `true` if the current action is `delete`, otherwise `false`.

### is('ip') detector

[](#isip-detector)

Checks whether the current client IP matches the IP or one of the IPs passed as an argument.

Example:

```
$this->getRequest()->is('ip', '99.99.99.99')
```

returns `true` if the current client IP is `99.99.99.99`, otherwise `false`.

Example:

```
$this->getRequest()->isAction('ip', ['99.99.99.99', '11.11.11.11']);
```

returns `true` if the current client IP is `99.99.99.99` or `11.11.11.11`, otherwise `false`.

### is('localhost') detector

[](#islocalhost-detector)

This is a quick alias for `is('ip')` detector.

Returns `true` if the current client IP matches localhost.

### is('trustedClient') detector

[](#istrustedclient-detector)

This is a quick alias for `is('ip')` detector.

Returns `true` if it is a trusted client.

Before using this detector, you should write trusted clients into the configuration.

For example, in your `bootstrap.php` file,

```
Configure::write('trustedIpAddress', ['45.46.47.48', '192.168.0.100']);
```

At this point,

```
$this->getRequest()->isAction('trustedClient')
```

returns `true` if the current client IP matches one of these.

Extends the View
----------------

[](#extends-the-view)

```
use Cake\Essentials\View\View;

class AppView extends View
{
}
```

If necessary, you can rewrite the default helpers by implementing the `initialize()` method and calling `parent::initialize()` **before** adding your own helpers.

```
class AppView extends View
    public function initialize(): void
    {
        parent::initialize();

        /**
         * These override any helpers defined by the parent.
         */
        $this->addHelper('Html');
        $this->addHelper('Form');
    }
}
```

Using Tooltips and Popovers
---------------------------

[](#using-tooltips-and-popovers)

Several helper methods support tooltips and popovers and can generate them automatically.

Please refer to the Bootstrap documentation before using them ([here](https://getbootstrap.com/docs/5.3/components/popovers) and [here](https://getbootstrap.com/docs/5.3/components/tooltips)).

Keep in mind that:

1. both depend on the third-party library *Popper*, which you need to include, or you can use `bootstrap.bundle.min.js`which contains *Popper*;
2. you will need to initialize both, as indicated in the documentation.
    You can include `webroot/js/enable-popovers.js` and `webroot/js/enable-tooltips.js` files in yourt layout, which will do it automatically:

```
echo $this->Html->script('/cake/essentials/js/enable-popovers.js');
echo $this->Html->script('/cake/essentials/js/enable-tooltips.js');
```

How to use Bake templates
-------------------------

[](#how-to-use-bake-templates)

In your `config/bootstrap.php` file:

```
Configure::write('Bake.theme', 'Cake/Essentials');
```

Or you can use the `--theme` option (or `--t`) with `Cake/Essentials` value.
Example:

```
bin/cake bake template ServiceStops -t Cake/Essentials -f
```

See also [CakePHP Bake 2.x Cookbook](https://book.cakephp.org/bake/2/en/development.html#creating-a-bake-theme).

###  Health Score

51

—

FairBetter than 96% of packages

Maintenance97

Actively maintained with recent releases

Popularity23

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity64

Established project with proven stability

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

Total

28

Last Release

49d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/56d4c91c4d1ce5952a13c723d4fd340f8a1220ba1ef0212bbdb9a6334c98b3b9?d=identicon)[mirko-pagliai](/maintainers/mirko-pagliai)

---

Top Contributors

[![mirko-pagliai](https://avatars.githubusercontent.com/u/293199?v=4)](https://github.com/mirko-pagliai "mirko-pagliai (545 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/mirko-pagliai-cakephp-essentials/health.svg)

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

###  Alternatives

[temporal/sdk

Temporal SDK

4002.2M18](/packages/temporal-sdk)[jason-munro/cypht

Lightweight Open Source webmail written in PHP and JavaScript

1.5k146.0k](/packages/jason-munro-cypht)[cakephp/bake

Bake plugin for CakePHP

11211.2M156](/packages/cakephp-bake)[terminal42/contao-mp_forms

An extension for Contao Open Source CMS to create multi steps forms using the form generator

2633.7k5](/packages/terminal42-contao-mp-forms)[drevops/git-artifact

Package artifact from your codebase in CI and push it to a separate git repo.

2133.2k](/packages/drevops-git-artifact)[dereuromark/cakephp-translate

A CakePHP plugin for managing translations

1710.4k](/packages/dereuromark-cakephp-translate)

PHPackages © 2026

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