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

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

sitepoint/container
===================

A simple, easy to follow PHP dependency injection container

v0.1.0(10y ago)43759MITPHP

Since Oct 24Pushed 10y ago6 watchersCompare

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

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

[![SitePoint](https://avatars2.githubusercontent.com/u/15340853?v=3&s=40)](https://avatars2.githubusercontent.com/u/15340853?v=3&s=40) Container
================================================================================================================================================

[](#-container)

[![Latest Stable Version](https://camo.githubusercontent.com/9620957e60387fbe1eda9e10b1289af91060dc8f175256cd3a6055da3f379c73/68747470733a2f2f706f7365722e707567782e6f72672f73697465706f696e742f636f6e7461696e65722f762f737461626c65)](https://packagist.org/packages/sitepoint/container)[![Build Status](https://camo.githubusercontent.com/ec66fc769d1382f19f141bb167c8070b87736d1e46cf3631496e48a6c09bf31c/68747470733a2f2f7472617669732d63692e6f72672f73697465706f696e742f436f6e7461696e65722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/sitepoint/Container)[![Code Coverage](https://camo.githubusercontent.com/ad9bdb2c2f689788bd38dc9806ea43b889a215fcb93f3729522b4e62556b838d/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f73697465706f696e742f436f6e7461696e65722f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/sitepoint/Container/?branch=master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/8582d8863d660c252e1ff98190e29c538469a452449ceb2964d237bcedea5e73/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f73697465706f696e742f436f6e7461696e65722f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/sitepoint/Container/?branch=master)[![Code Climate](https://camo.githubusercontent.com/77c5cc67609a97083c9d13f373ee32ed23840b5ea72a16c3efa267b9d74e3183/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f73697465706f696e742f436f6e7461696e65722f6261646765732f6770612e737667)](https://codeclimate.com/github/sitepoint/Container)[![Total Downloads](https://camo.githubusercontent.com/e44be796dc860cba8c712a11fe7e0e50e5ab964ce399edf854464c4b839e6a77/68747470733a2f2f706f7365722e707567782e6f72672f73697465706f696e742f636f6e7461696e65722f646f776e6c6f616473)](https://packagist.org/packages/sitepoint/container)[![License](https://camo.githubusercontent.com/db271f5f001bb1e0bf14048e5709a9309bbf2f90d04f7d10968b2714fae7339b/68747470733a2f2f706f7365722e707567782e6f72672f73697465706f696e742f636f6e7461696e65722f6c6963656e7365)](https://packagist.org/packages/sitepoint/container)

A simple, easy to follow PHP dependency injection container. Designed to be forked, modified, extended and hacked.

How to Use
----------

[](#how-to-use)

Although it isn't required to do so, a good practice is to split up the configuration for our container. In this example we'll use three files to create our container for the Monolog component.

Another good practice is to use class and interface paths as service names. This provides a stricter naming convention that gives us more information about the services.

In the service definitions file, we define three services. All of the services require constructor injection arguments. Some of these arguments are imported from the container parameters and some are defined directly. The logger service also requires two calls to the `pushHandler` method, each with a different handler service imported.

```
