PHPackages                             chinpei215/cakephp-eager-loader - 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. chinpei215/cakephp-eager-loader

ActiveCakephp-plugin

chinpei215/cakephp-eager-loader
===============================

CakePHP 2.x plugin to make it possible to eager load

0.4.0(9y ago)613.9k↓100%5[4 issues](https://github.com/chinpei215/cakephp-eager-loader/issues)[1 PRs](https://github.com/chinpei215/cakephp-eager-loader/pulls)MITPHP

Since Jan 11Pushed 8y ago4 watchersCompare

[ Source](https://github.com/chinpei215/cakephp-eager-loader)[ Packagist](https://packagist.org/packages/chinpei215/cakephp-eager-loader)[ Docs](https://github.com/chinpei215/cakephp-eager-loader)[ RSS](/packages/chinpei215-cakephp-eager-loader/feed)WikiDiscussions master Synced today

READMEChangelog (8)Dependencies (1)Versions (13)Used By (0)

[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.txt)[![Build Status](https://camo.githubusercontent.com/967459ca7b8772881d7f38b530d75dc52cfb159b9ac357b2833f7d46d1acfcf7/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f6368696e7065693231352f63616b657068702d65616765722d6c6f616465722f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/chinpei215/cakephp-eager-loader)[![Coverage Status](https://camo.githubusercontent.com/13394948c21e8111a86c8a3209c263234ab089f6182ad031f636df4b8f51b6e5/68747470733a2f2f696d672e736869656c64732e696f2f636f766572616c6c732f6368696e7065693231352f63616b657068702d65616765722d6c6f616465722e7376673f7374796c653d666c61742d737175617265)](https://coveralls.io/r/chinpei215/cakephp-eager-loader?branch=master)[![Scrutinizer](https://camo.githubusercontent.com/20487dc3d8d721c00f82cc61d7d5603ad4f02965e7bc0bf541d5a1033c03b79e/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6368696e7065693231352f63616b657068702d65616765722d6c6f616465722f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/chinpei215/cakephp-eager-loader)

EagerLoader Plugin for CakePHP 2.x
==================================

[](#eagerloader-plugin-for-cakephp-2x)

An eager loading beahavior plugin for CakePHP 2.x which is highly compatible to the [Containable behavior](http://book.cakephp.org/2.0/en/core-libraries/behaviors/containable.html)but generates better queries.

Requirements
------------

[](#requirements)

- CakePHP 2.x
- PHP 5.3+

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

[](#installation)

See the [How to Install Plugins](http://book.cakephp.org/2.0/en/plugins/how-to-install-plugins.html)in the CakePHP documentation for general help.

- Put the `EagerLoader` directory into your plugin directory or install the plugin with [Composer](https://getcomposer.org/) from the directory where your **composer.json** file is located:

```
php composer.phar require chinpei215/cakephp-eager-loader
```

- Load the plugin in your **app/Config/bootstrap.php** file:

```
CakePlugin::load('EagerLoader');
```

- And [enable the behavior](http://book.cakephp.org/2.0/en/models/behaviors.html#using-behaviors)in your models or in your **app/Model/AppModel.php**:

```
class Post extends AppModel {
    public $actsAs = array('EagerLoader.EagerLoader');
}
```

Usage
-----

[](#usage)

```
$Comment->find('first', [
	'contain' => [
		'Article.User.Profile',
		'User.Profile',
	]
]);
```

`EagerLoaderBehavior` has a high compatibility with `ContainableBehavior`, but generates better queries. In the above example, only 2 queries will be executed such as the following:

```
SELECT
	Comment.id, ...
FROM
	comments AS Comment
	LEFT JOIN articles AS Article ON (Comment.article_id = Article.id)
	LEFT JOIN users AS User ON (Article.user_id = User.id)
	LEFT JOIN profiles AS Profile ON (User.id = Profile.user_id)
WHERE
	1 = 1
```

```
SELECT
	User.id, ...
FROM
	users AS User
	LEFT JOIN profiles AS Profile ON (User.id = Profile.user_id)
WHERE
	User.id IN (1, 2, 3)
```

If using `ContainableBehavior`, how many queries are executed? 10 or more?

Incompatibility problems
------------------------

[](#incompatibility-problems)

`EagerLoaderBehavior` returns almost same results as `ContainableBehavior`, however you might encounter incompatibility problems between the 2 behaviors. For example `EagerLoaderBehavior::contain()` is not implemented yet.

Then disabling `EagerLoaderBehavior` on the fly, you can use `ContainableBehavior::contain()` instead:

```
$Comment->Behaviors->disable('EagerLoader');
$Comment->Behaviors->load('Containable');
$Comment->contain('Article');
$result = $Comment->find('first');
```

For your information, `EagerLoaderBehavior` can be coexistent with `ContainableBehavior`.

```
$actsAs = [
	'EagerLoader.EagerLoader', // Requires higher priority than Containable
	'Containable'
]
```

Using this way, you need not to call `load('Containable')` in the above example.

###  Health Score

31

—

LowBetter than 71% of packages

Maintenance7

Infrequent updates — may be unmaintained

Popularity31

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 86.9% 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 ~55 days

Recently: every ~88 days

Total

8

Last Release

3336d ago

### Community

Maintainers

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

---

Top Contributors

[![chinpei215](https://avatars.githubusercontent.com/u/7399393?v=4)](https://github.com/chinpei215 "chinpei215 (73 commits)")[![ravage84](https://avatars.githubusercontent.com/u/625761?v=4)](https://github.com/ravage84 "ravage84 (11 commits)")

---

Tags

cakephploadeagercontaincontainable

### Embed Badge

![Health badge](/badges/chinpei215-cakephp-eager-loader/health.svg)

```
[![Health](https://phpackages.com/badges/chinpei215-cakephp-eager-loader/health.svg)](https://phpackages.com/packages/chinpei215-cakephp-eager-loader)
```

###  Alternatives

[cakedc/migrations

Migrations Plugin for CakePHP

3451.1M50](/packages/cakedc-migrations)[slywalker/boost_cake

BoostCake is a plugin for CakePHP using Bootstrap

279508.0k1](/packages/slywalker-boost-cake)[jedrzej/pimpable

Laravel 4/5/6 package that allows to dynamically filter, sort and eager load relations for your models using request parameters

105176.5k1](/packages/jedrzej-pimpable)[jedrzej/withable

Withable trait for Laravel's Eloquent models

25190.3k2](/packages/jedrzej-withable)[chronon/mobile_detect

A CakePHP plugin component for identifying mobile devices using the Mobile\_Detect project.

24243.7k1](/packages/chronon-mobile-detect)[hiromi2424/transition

Transition component is a CakePHP component to help your transitional pages logic.

4555.7k](/packages/hiromi2424-transition)

PHPackages © 2026

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