PHPackages                             cora/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. cora/container

ActiveLibrary

cora/container
==============

A dependency injection container with a focus on being useful throughout an application, not just for services.

v1.0.1(6y ago)01MITPHPPHP &gt;=5.3.0

Since Aug 15Pushed 6y ago1 watchersCompare

[ Source](https://github.com/joebubna/cora-container)[ Packagist](https://packagist.org/packages/cora/container)[ RSS](/packages/cora-container/feed)WikiDiscussions master Synced 4d ago

READMEChangelogDependencies (3)Versions (3)Used By (0)

Cora Container
==============

[](#cora-container)

Terms:
------

[](#terms)

DI = Dependency Injection

The Big Idea
------------

[](#the-big-idea)

This library helps you manage dependency injection for your application in a sane and easy to understand manner. Rather than focus just on "services" or utilize magic to inject them (like some libraries and frameworks), this library gives you finer control over the injection process than probably any tool in existance.

Using this tool you can wire up any class within your app for injection - even those that require runtime input. The dependency injections will happen recursively, potentially making a series of class instantiations that would be horrendous to do by hand a breeze. By handling all the injections for you, this also means you can change class signatures and add new dependencies in the future without having to modify every instantiation throughout your codebase.

Finally, if you hate cluttering up your codebase with factory classes (like me), rejoice! Each of the class definitions you create as part of wiring up your app for dependency injection can also be easily re-used to create factories when dynamic object creation is needed within a class.

Basic Usage
-----------

[](#basic-usage)

Everything revolves around the idea of defining resources for your application and how to create them.

### Simple Example

[](#simple-example)

Say you had the following class that needed a database abstraction class as a dependency:

```
