PHPackages                             ivangrigorov/php-simple-dicontainer - 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. ivangrigorov/php-simple-dicontainer

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

ivangrigorov/php-simple-dicontainer
===================================

DI container for php projects

1.0.0.0(6y ago)26MITPHPPHP ^5.3.3 || ^7.0CI failing

Since Aug 11Pushed 6y ago1 watchersCompare

[ Source](https://github.com/IvanGrigorov/PHPDI)[ Packagist](https://packagist.org/packages/ivangrigorov/php-simple-dicontainer)[ Docs](https://github.com/IvanGrigorov/PHPDI)[ RSS](/packages/ivangrigorov-php-simple-dicontainer/feed)WikiDiscussions master Synced 2mo ago

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

PHPDI
=====

[](#phpdi)

Welcome to the PHPDI project.
-----------------------------

[](#welcome-to-the-phpdi-project)

---

Hi, 😃 👋

This is a minimalistic PHP project with the aim to provide a simple but powerful solution to anyone that thinks **Dependency Injection** (DI) is something useful.

*PHPDI* is a DI container, allowing you to control your dependencies throughout your whole project. I won't explain here what DI and containers are in detail. For more information, you can visit this site 👉 [HERE](https://en.wikipedia.org/wiki/Dependency_injectionttps://www.google.com)

- [PHPDI](#phpdi)
    - [Welcome to the PHPDI project](#welcome-to-the-phpdi-project)
    - [So, now about the project](#so-now-about-the-project)
    - [**PHPDI\_v1.1**](#phpdiv11)
        - [Config:](#config)
        - [Advantages](#advantages)
            - [No more endless `required_once`](#no-more-endless-requiredonce)
            - [Scope Check](#scope-check)
            - [Logger options](#logger-options)
            - [Exception Logger options](#exception-logger-options)
            - [Follow the best desgin principles](#follow-the-best-desgin-principles)
        - [How to use](#how-to-use)
    - [**PHPDI\_v1.2**](#phpdiv12)
    - [Conclusion](#conclusion)

So, now about the project
-------------------------

[](#so-now-about-the-project)

---

The whole design behind the realisation is *Convention over Configuration*. That doesn't mean that you won't need to make some tweeks and adjustments, but you won't need to do anything special.

**Currently there are two versions of the project: This is the official second version. The second version contains everything from the first one.**

**Version one will not be maintained anymore.**

*Beta* state means, that everything tested so far works, but that there might be some small bugs.

*Alpha* state means, that it is still in phase of testing and might be unstable, but that you can always give it a try and report issues, bugs, and missing features.

**PHPDI** [![Build Status](https://camo.githubusercontent.com/a91dbd477e302f7b925ad608d0a614d7de20016f3e2f691cf98c202d37497522/68747470733a2f2f7472617669732d63692e6f72672f4976616e477269676f726f762f50485044492e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/IvanGrigorov/PHPDI) [![(https://img.shields.io/badge/coverage-14%25-orange)](https://camo.githubusercontent.com/c2d5f3c478db4699c9012a87affffa13b52411fc4f70f46b876d5b0596480264/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f636f7665726167652d31342532352d6f72616e6765)](https://camo.githubusercontent.com/c2d5f3c478db4699c9012a87affffa13b52411fc4f70f46b876d5b0596480264/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f636f7665726167652d31342532352d6f72616e6765) [![(https://img.shields.io/badge/version-stable-green)](https://camo.githubusercontent.com/5da71a26259b5cadf43cb2863a6cd2bd97e7e51a89f0fa3f57e6bf3701d54c88/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f76657273696f6e2d737461626c652d677265656e)](https://camo.githubusercontent.com/5da71a26259b5cadf43cb2863a6cd2bd97e7e51a89f0fa3f57e6bf3701d54c88/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f76657273696f6e2d737461626c652d677265656e)
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

[](#phpdi----)

### Config:

[](#config)

Config optionsDescriptionObject type (Injection)classNameName of the class to injectObject, with parameterless constructorisSingletonCreates singleton objectObject, with parameterless constructor[![Parameterless Injection](./doc/parameterless.png "Parameterless Injection")](./doc/parameterless.png)

Config optionsDescriptionObject type (Injection)nameName of the valueValue type objecttypeType of the object (string, int and so on)Value type objectvalueValue, desired to be returnedValue type object[![Valuetype Injection](./doc/valuetype.png "Valuetype Injection")](./doc/valuetype.png)

Config optionsDescriptionObject type (Injection)classNameName of the class to injectObject, with constructor with parametersisSingletonCreates singleton objectObject, with constructor with parametersparamsThe params for constructorObject, with constructor with parameters[![Injection with params](./doc/params.png "Injection with params")](./doc/params.png)

In the params, the root node is the name of parameter in the constructor and in it the defaulValue.

***IMPORTANT:*** **The config currently does not allow the use of reference type parameters when calling an injection. To get a reference type object when calling a dependency, you should use the container in the constructor in the class of the dependency and set its properties with the injected objects there.**

See the examples in the project.

### Advantages

[](#advantages)

#### No more endless `required_once`

[](#no-more-endless-required_once)

There is an AutoLoader, which loads the classes automatically *just* when needed. Just specify the path in the `LoaderConfig.php` file once.

#### Easy change between service (injection) providers

[](#easy-change-between-service-injection-providers)

You can easily switch between different configured injection configurations for development, testing, and production.

#### Scope Check

[](#scope-check)

Be sure that only allowed classes can create instances and use object dependencies.

#### Logger options

[](#logger-options)

Option to log all injections - Which examples are used and where.

#### Exception Logger options

[](#exception-logger-options)

Option to log some catched exceptions - Which examples are used and where.

#### Follow the best desgin principles

[](#follow-the-best-desgin-principles)

Option to check whether all injections have an interface inherited by them.

All these things, can be modified in the Config.php

#### Lazy Instantiation

[](#lazy-instantiation)

Initially creates a proxy object which loads the whole object only when used.

#### Easier configs

[](#easier-configs)

The injection configs are now exported to json files, which makes working with different ones very easy.

### How to use

[](#how-to-use)

**composer require ivangrigorov/php-simple-dicontainer**

**Before use, you can delete the doc folder, `index.php`, `IURLParser.php`, and `URLParser.php` (which are used only for the tests).****Update the config dependencies json file.**

1. In your composer.json file add `"autoload": { "classmap": ["vendor/ivangrigorov/php-simple-dicontainer/DI/Lib/"] }`
2. Run `composer update` command
3. In your initial file add `require __DIR__."/vendor/autoload.php"; `
4. Get instance of the container (static method)
5. Call the requested method with the correct parameters. (To get reference type object pass the className with the "I" prefix -&gt; IclassName). 3.1. Example for parameter for getInjectionWithParams method - `["params" => array(["name" => "url"])]);`If "value" is not given, the default from the config is used.

Conclusion
----------

[](#conclusion)

If you've read everything up to this point, congratulations 👏 and thank you for your interest 👍

The license for this is open source and free to use. I will appreciate a star or a good word if you think it deserves it.

You can raise issues and report problems or missing features. You can help with ideas and solutions too.

For contact - ivangrigorov9 at gmail.com

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 96.6% 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

Unknown

Total

1

Last Release

2463d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/1d203d987d6e10ce37506de8461d8d4de7b445aac38e4881a8f99151d900c27f?d=identicon)[IvanGrigorov](/maintainers/IvanGrigorov)

---

Top Contributors

[![IvanGrigorov](https://avatars.githubusercontent.com/u/10940601?v=4)](https://github.com/IvanGrigorov "IvanGrigorov (28 commits)")[![Maikuolan](https://avatars.githubusercontent.com/u/12571108?v=4)](https://github.com/Maikuolan "Maikuolan (1 commits)")

---

Tags

dependency-injectiondependency-injection-containerinversion-of-controlcontainerdependency-injectiondi

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/ivangrigorov-php-simple-dicontainer/health.svg)

```
[![Health](https://phpackages.com/badges/ivangrigorov-php-simple-dicontainer/health.svg)](https://phpackages.com/packages/ivangrigorov-php-simple-dicontainer)
```

###  Alternatives

[php-di/php-di

The dependency injection container for humans

2.8k48.9M991](/packages/php-di-php-di)[aura/di

A serializable dependency injection container with constructor and setter injection, interface and trait awareness, configuration inheritance, and much more.

356968.3k58](/packages/aura-di)[mrclay/props-dic

Props is a simple DI container that allows retrieving values via custom property and method names

3611.7M3](/packages/mrclay-props-dic)[slince/di

A flexible dependency injection container

20260.4k6](/packages/slince-di)[capsule/di

A PSR-11 compliant autowiring dependency injection container.

2857.5k2](/packages/capsule-di)

PHPackages © 2026

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