PHPackages                             gr8abbasi/php-di-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. [Framework](/categories/framework)
4. /
5. gr8abbasi/php-di-container

ActiveLibrary[Framework](/categories/framework)

gr8abbasi/php-di-container
==========================

Simple Dependency Injection Container/Library for PHP

1.0(9y ago)022MITPHPPHP &gt;=5.5

Since Nov 5Pushed 9y ago2 watchersCompare

[ Source](https://github.com/gr8abbasi/php-di-container)[ Packagist](https://packagist.org/packages/gr8abbasi/php-di-container)[ Docs](https://github.com/gr8abbasi/php-di-container)[ RSS](/packages/gr8abbasi-php-di-container/feed)WikiDiscussions master Synced today

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

php-di-container
================

[](#php-di-container)

PHP DI Container resolves dependencies for php application using Dependency Injection. And it provides a simple container for all depnedencies as well. It can take dependencies as argument to other classes and resolve them efficiently. Good thing about container is you can specify dependencies in many formats:

\##PHP ##JSON ##YAML ##INI

PHP DI Container is capable of reading configuration from above four formats and load them as services to the container using lazy loading using [PHP Simple Config](https://github.com/mcustiel/php-simple-config)While using [PHP Simple Config](https://github.com/mcustiel/php-simple-config) can use cache for our configuration as well to boost the performance. Please go through details about [PHP Simple Config](https://github.com/mcustiel/php-simple-config).

Future plan is to allow simple php container without any config file for small applications.

Note: Currently its only support PHP version 5.5 and above

Build &amp; Code Details: [![Build Status](https://camo.githubusercontent.com/b1081321b6919894a7c6fd3e15bdef1c90a29ee83bdd12d97f5853f05c0cd654/68747470733a2f2f7472617669732d63692e6f72672f6772386162626173692f7068702d64692d636f6e7461696e65722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/gr8abbasi/php-di-container)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/5b1a290d188965d3b15b8ff918a35a33904081b2cedcb565066c573af5c0e27b/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6772386162626173692f7068702d64692d636f6e7461696e65722f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/gr8abbasi/php-di-container/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/30bd77e3d1d7ffa91bdfb87a094b31f1f5c70493d464b0f3445de5285da22ea2/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6772386162626173692f7068702d64692d636f6e7461696e65722f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/gr8abbasi/php-di-container/?branch=master)

Package Details:

Install using Composer
======================

[](#install-using-composer)

Add following dependency to your `composer.json`

```
{
  require: {
     // Add this line to your `composer require` as shown below
     "gr8abbasi/php-di-container":"dev-master"
  }
}
```

Create a configuration file in the desired formate and use desired reader by default service loader will use php config file reader

```
use Mcustiel\Config\Drivers\Reader\php\Reader as PhpReader;
use Mcustiel\Config\Drivers\Reader\ini\Reader as IniReader;
use Mcustiel\Config\Drivers\Reader\json\Reader as JsonReader;
use Mcustiel\Config\Drivers\Reader\yaml\Reader as YamlReader;
```

PHP configuration file looks like something below and you can see it contains others classes as dependencies as well.

PHP Example:
============

[](#php-example)

```
