PHPackages                             muffin/footprint - 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. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. muffin/footprint

ActiveCakephp-plugin[Authentication &amp; Authorization](/categories/authentication)

muffin/footprint
================

CakePHP plugin to allow passing currently logged in user to model layer

4.0.1(2y ago)95665.9k↓31.1%223MITPHPCI passing

Since Jun 2Pushed 2mo ago8 watchersCompare

[ Source](https://github.com/UseMuffin/Footprint)[ Packagist](https://packagist.org/packages/muffin/footprint)[ Docs](https://github.com/usemuffin/footprint)[ RSS](/packages/muffin-footprint/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (10)Dependencies (3)Versions (19)Used By (3)

Footprint
=========

[](#footprint)

[![Build Status](https://camo.githubusercontent.com/e4771d1a3f33104e82fa83cb8880a785ae006396e6680d14b1fada059cdbfb0b/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f5573654d756666696e2f466f6f747072696e742f63692e796d6c3f7374796c653d666c61742d737175617265)](https://github.com/UseMuffin/Footprint/actions?query=workflow%3ACI+branch%3Amaster)[![Coverage](https://camo.githubusercontent.com/d9a99142efee2d13b5779575f9a0d1c756a57d19b84ea9fe9c18cc721e47c6d2/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f6769746875622f5573654d756666696e2f466f6f747072696e742f6d61737465723f7374796c653d666c61742d737175617265)](https://codecov.io/github/UseMuffin/Footprint)[![Total Downloads](https://camo.githubusercontent.com/fb9ac855cc9c5e9224edb8b1c1059c8ce6312dbbde6db5ec30365e1550c42dab/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d756666696e2f666f6f747072696e742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/muffin/footprint)[![License](https://camo.githubusercontent.com/942e017bf0672002dd32a857c95d66f28c5900ab541838c6c664442516309c8a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e7376673f7374796c653d666c61742d737175617265)](LICENSE)

This plugin allows you to pass the currently logged in user info to the model layer of a CakePHP application.

It comes bundled with the `FootprintBehavior` to allow you control over columns such as `user_id`, `created_by`, `company_id` similar to the core's `TimestampBehavior`.

Install
-------

[](#install)

Using [Composer](http://getcomposer.org):

```
composer require muffin/footprint
```

You then need to load the plugin by running console command:

```
bin/cake plugin load Muffin/Footprint
```

The Footprint plugin must be loaded **before** the [Authentication](https://github.com/cakephp/authentication) plugin, so you should updated your `config/plugins.php` or `Application::bootstrap()` accordingly.

Usage
-----

[](#usage)

### Middleware

[](#middleware)

Add the `FootprintMiddleware` to the middleware queue in your `Application::middleware()`method:

```
$middleware->add('Muffin/Footprint.Footprint');
```

It must be added **after** `AuthenticationMiddleware` to ensure that it can read the identify info after authentication is done.

If you don't have direct access to the place where `AuthenticationMiddleware` is added then check [here](#adding-middleware-via-event).

### Behavior

[](#behavior)

To use the included behavior to automatically update the `created_by` and `modified_by`fields of a record for example, add the following to your table's `initialize()` method:

```
$this->addBehavior('Muffin/Footprint.Footprint');
```

You can customize that like so:

```
$this->addBehavior('Muffin/Footprint.Footprint', [
    'events' => [
        'Model.beforeSave' => [
            'user_id' => 'new',
            'company_id' => 'new',
            'modified_by' => 'always'
        ]
    ],
    'propertiesMap' => [
        'company_id' => '_footprint.company.id',
    ],
]);
```

This will insert the currently logged in user's primary key in `user_id` and `modified_by`fields when creating a record, on the `modified_by` field again when updating the record and it will use the associated user record's company `id` in the `company_id` field when creating a record.

You can also provide a closure that accepts an EntityInterface and returns a bool:

```
$this->addBehavior('Muffin/Footprint.Footprint', [
    'events' => [
        'Model.beforeSave' => [
            'user_id' => 'new',
            'company_id' => 'new',
            'modified_by' => 'always',
            'deleted_by' => function ($entity): bool {
                return $entity->deleted !== null;
            },
        ]
    ],
]);
```

### Adding middleware via event

[](#adding-middleware-via-event)

In some cases you don't have direct access to the place where the `AuthenticationMiddleware` is added. Then you will have to add this to your `src/Application.php`

```
use Authentication\Middleware\AuthenticationMiddleware;
use Cake\Event\EventInterface;
use Cake\Http\MiddlewareQueue;
use Muffin\Footprint\Middleware\FootprintMiddleware;

// inside the bootstrap() method
$this->getEventManager()->on(
    'Server.buildMiddleware',
    function (EventInterface $event, MiddlewareQueue $middleware) {
        $middleware->insertAfter(AuthenticationMiddleware::class, FootprintMiddleware::class);
    }
);
```

Patches &amp; Features
----------------------

[](#patches--features)

- Fork
- Mod, fix
- Test - this is important, so it's not unintentionally broken
- Commit - do not mess with license, todo, version, etc. (if you do change any, bump them into commits of their own that I can ignore when I pull)
- Pull request - bonus point for topic branches

Bugs &amp; Feedback
-------------------

[](#bugs--feedback)

License
-------

[](#license)

Copyright (c) 2015-Present, [Use Muffin](http://usemuffin.com) and licensed under [The MIT License](http://www.opensource.org/licenses/mit-license.php).

###  Health Score

56

—

FairBetter than 97% of packages

Maintenance57

Moderate activity, may be stable

Popularity53

Moderate usage in the ecosystem

Community30

Small or concentrated contributor base

Maturity72

Established project with proven stability

 Bus Factor1

Top contributor holds 75.4% 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 ~160 days

Recently: every ~199 days

Total

18

Last Release

959d ago

Major Versions

1.2.2 → 2.0.0-beta2020-01-20

1.x-dev → 2.0.0-RC2020-08-19

2.0.3 → 3.0.0-beta12021-09-13

3.x-dev → 4.0.02023-10-10

### Community

Maintainers

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

---

Top Contributors

[![ADmad](https://avatars.githubusercontent.com/u/142658?v=4)](https://github.com/ADmad "ADmad (135 commits)")[![ypnos](https://avatars.githubusercontent.com/u/8481470?v=4)](https://github.com/ypnos "ypnos (12 commits)")[![jadb](https://avatars.githubusercontent.com/u/33527?v=4)](https://github.com/jadb "jadb (6 commits)")[![JacobAGTyler](https://avatars.githubusercontent.com/u/3827053?v=4)](https://github.com/JacobAGTyler "JacobAGTyler (4 commits)")[![LordSimal](https://avatars.githubusercontent.com/u/9105243?v=4)](https://github.com/LordSimal "LordSimal (3 commits)")[![inoas](https://avatars.githubusercontent.com/u/20972207?v=4)](https://github.com/inoas "inoas (3 commits)")[![altamira-sykora](https://avatars.githubusercontent.com/u/89403623?v=4)](https://github.com/altamira-sykora "altamira-sykora (2 commits)")[![dakota](https://avatars.githubusercontent.com/u/83255?v=4)](https://github.com/dakota "dakota (2 commits)")[![mrothauer](https://avatars.githubusercontent.com/u/527787?v=4)](https://github.com/mrothauer "mrothauer (2 commits)")[![jeremyharris](https://avatars.githubusercontent.com/u/184903?v=4)](https://github.com/jeremyharris "jeremyharris (2 commits)")[![jharder](https://avatars.githubusercontent.com/u/76728?v=4)](https://github.com/jharder "jharder (1 commits)")[![eymen-elkum](https://avatars.githubusercontent.com/u/2862528?v=4)](https://github.com/eymen-elkum "eymen-elkum (1 commits)")[![japita-se](https://avatars.githubusercontent.com/u/6206959?v=4)](https://github.com/japita-se "japita-se (1 commits)")[![challgren](https://avatars.githubusercontent.com/u/88909?v=4)](https://github.com/challgren "challgren (1 commits)")[![justinatack](https://avatars.githubusercontent.com/u/6056502?v=4)](https://github.com/justinatack "justinatack (1 commits)")[![lorenzo](https://avatars.githubusercontent.com/u/37621?v=4)](https://github.com/lorenzo "lorenzo (1 commits)")[![modpluz](https://avatars.githubusercontent.com/u/3523537?v=4)](https://github.com/modpluz "modpluz (1 commits)")[![waspinator](https://avatars.githubusercontent.com/u/100416?v=4)](https://github.com/waspinator "waspinator (1 commits)")

---

Tags

cakephpcakephp-pluginphpcakephpmuffinfootprint

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/muffin-footprint/health.svg)

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

###  Alternatives

[dereuromark/cakephp-tinyauth

A CakePHP plugin to handle user authentication and authorization the easy way.

131240.2k13](/packages/dereuromark-cakephp-tinyauth)[cakephp/debug_kit

CakePHP Debug Kit

86314.7M171](/packages/cakephp-debug-kit)[cakedc/users

Users Plugin for CakePHP

525928.0k20](/packages/cakedc-users)[cakephp/bake

Bake plugin for CakePHP

11212.0M202](/packages/cakephp-bake)[dereuromark/cakephp-queue

The Queue plugin for CakePHP provides deferred task execution.

308954.9k25](/packages/dereuromark-cakephp-queue)[dereuromark/cakephp-ide-helper

CakePHP IdeHelper Plugin to improve auto-completion

1882.3M44](/packages/dereuromark-cakephp-ide-helper)

PHPackages © 2026

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