Skip to content

Guide

The Tools plugin extends CakePHP with the small-to-medium utilities you keep writing across projects: model & entity base classes, view helpers, behaviors, and components. It also depends on the cakephp-shim plugin, so installing Tools brings the 4.x → 5.x compatibility helpers along for the ride.

Setup

  • Installation — composer require, plugin loading, optional config.
  • Upgrade Guide — moving from 4.x to 5.x.
  • Shims — pointer to the cakephp-shim plugin (a Tools dependency).
  • Tools Backend — opt-in admin backend for inspecting parts of the toolbox.

Basic enhancements

Extend the Tools plugin Table and Entity base classes to pick up a few defaults:

php
namespace App\Model\Table;

use Tools\Model\Table\Table;

class UsersTable extends Table {}
php
namespace App\Model\Entity;

use Tools\Model\Entity\Entity;

class User extends Entity {}

In your AppController, load the Common component:

php
use Tools\Controller\Controller;

class AppController extends Controller {
    public function initialize(): void {
        parent::initialize();
        $this->loadComponent('Tools.Common');
    }
}

In your AppView, the most useful helpers in one place:

php
public function initialize(): void {
    parent::initialize();
    $this->loadHelper('Tools.Common');
    $this->loadHelper('Tools.Format');
}

The Common component auto-trims POST data so notEmpty validation behaves predictably. The Tools controller adds a few small fixes (e.g. cache disabling that also covers older browsers).

Where to next

Pick a section from the sidebar:

  • Behaviors — 10 ORM behaviors.
  • Helpers — 9 view helpers.
  • Components — 3 controller components.
  • Model — Table base, Tokens, Enum, StaticEnum.
  • Reference — Authentication, Mailer, Controller, Command, I18n, URL, Error, Utility, Widget.

Released under the MIT License.