PHPackages                             burriko/cake-container - 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. [PSR &amp; Standards](/categories/psr-standards)
4. /
5. burriko/cake-container

ActiveCakephp-plugin[PSR &amp; Standards](/categories/psr-standards)

burriko/cake-container
======================

Adds League's DI Container to CakePHP 2.x

1.0.1(9y ago)1498MITPHPPHP &gt;=5.4.0

Since Jul 31Pushed 9y ago1 watchersCompare

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

READMEChangelog (2)Dependencies (2)Versions (3)Used By (0)

CakePHP Container
=================

[](#cakephp-container)

An easy way to add a good dependency injection container to Cakephp 2 applications.

This installs League's Container, injects it into controllers, and adds it into CakeRegistry so you can access it as a singleton from anywhere else you may need it.

Why?
----

[](#why)

I support a number of legacy CakePHP applications, and the lack of a container or a nice way to do DI was annoying.

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

[](#installation)

Install with composer.

```
composer require burriko/cake-container

```

Load the plugin in Config/bootstrap.php. Bootstrap needs to be set to true.

```
CakePlugin::loadAll(['CakeContainer' => ['bootstrap' => true]]);

```

Usage
-----

[](#usage)

Create a file at Config/container.php to contain your container config. In here you can specify anything from the [League Container docs](http://container.thephpleague.com). For example, to load a service provider your config file would contain something like:

```
