mirko-pagliai/cakephp-entities-logger

Entities Logger plugin for CakePHP

dev-main 2025-06-27 21:30 UTC

This package is auto-updated.

Last update: 2025-06-27 21:30:26 UTC


README

Software License CI codecov Codacy Badge CodeFactor CodeFactor

screenshot_phpmyadmin.png

From this screenshot, which shows the table seen by PhpMyAdmin, we see the logs generated by two different entities, created, modified or deleted by different users.

Installation

You can install the plugin via composer:

composer require --prefer-dist mirko-pagliai/cakephp-entities-logger

Then you have to load the plugin. For more information on how to load the plugin, please refer to the CakePHP documentation.

Simply, you can execute the shell command to enable the plugin:

bin/cake plugin load Cake/EntitiesLogger

This would update your application's bootstrap method.

Create the table

Now you need to create the table that the plugin will use to keep changes to the entities you want.

The best way is using migrations:

bin/cake migrations migrate -p Cake/EntitiesLogger

Instead, if you want to verify that the plugin migrations have been applied correctly:

bin/cake migrations status -p Cake/EntitiesLogger

Add the behavior

Add the Cake/EntitiesLogger.EntitiesLog behavior to the tables you want.

Inside the initialize() method of your tables:

namespace App\Model\Table;

use Cake\ORM\Table;

class ArticlesTable extends Table
{
    public function initialize(array $config): void
    {
        // ...
        
        $this->addBehavior('Cake/EntitiesLogger.EntitiesLog');
        
        // ...
    }
}