PHPackages                             dconstructor/dconstructor - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. dconstructor/dconstructor

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

dconstructor/dconstructor
=========================

dependency injection for lazy p

1.0.0(8y ago)017MITPHP

Since Dec 14Pushed 8y ago1 watchersCompare

[ Source](https://github.com/jonathankowalski/dconstructor)[ Packagist](https://packagist.org/packages/dconstructor/dconstructor)[ RSS](/packages/dconstructor-dconstructor/feed)WikiDiscussions master Synced yesterday

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

Dconstructor [![Build Status](https://camo.githubusercontent.com/78bb0ed048b871d052331c7ab68c5dfac3f534b6c26e4cf04c2e98390d84e2c2/68747470733a2f2f7472617669732d63692e6f72672f6a6f6e617468616e6b6f77616c736b692f6f6d672e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/jonathankowalski/dconstructor) [![Coverage Status](https://camo.githubusercontent.com/66ef616bf063e451f74ca88278e3d04917d804e2ae7bfe77820781286b0ee39d/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f6a6f6e617468616e6b6f77616c736b692f64636f6e7374727563746f722f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/jonathankowalski/dconstructor?branch=master)
===================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================

[](#dconstructor--)

Dependency Injection for Lazy People
------------------------------------

[](#dependency-injection-for-lazy-people)

### (all of us btw)

[](#all-of-us-btw)

Everybody likes dependency injection (and if it is not your case, you should). However dependency injection sometimes leads us to write of useless code and that, everybody hates.

The purpose of Dconstructor is to free you from certain portions of code which do not serve in much, the happiness of developers as a matter of fact.

Indeed nowadays, we repeat many things, in the properties, in the signature of the constructor, in the body of the constructor. Repeat is null, time to dconstructor KISS

Dconstructor
------------

[](#dconstructor)

```
class UserManager
{
    /**
     * @var Mailer
     */
    private $mailer;

    public function register($email){
        //some code
        $this->mailer->send($email, "Hello !");
    }
}

class Mailer
{
    public function send($recipient, $message)
    {
        //some code
    }
}
```

Without DI
----------

[](#without-di)

just take a simple example

```
class UserManager
{
    public function register($email){
        //some code
        $mailer = new Mailer();
        $mailer->send($email, "Hello !");
    }
}

class Mailer
{
    public function send($recipient, $message)
    {
        //some code
    }
}
```

Classic DI
----------

[](#classic-di)

```
class UserManager
{
    /**
     * @var Mailer
     */
    private $mailer;

    public function __construct(Mailer $mailer) {
        $this->mailer = $mailer;
    }

    public function register($email){
        //some code
        $this->mailer->send($email, "Hello !");
    }
}

class Mailer
{
    public function send($recipient, $message)
    {
        //some code
    }
}
```

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

[](#installation)

```
$ composer require dconstructor/dconstructor
```

Usage
-----

[](#usage)

Dconstructor is a simple DI container use it as usual

```
$container = new Container();

$container->set('foo','bar');
```

Dconstructor will make injection for you, in our example above for instantiate a new UserManager just call it

```
$container = new Container();

$userManager = $container->get('UserManager');
```

### Singleton

[](#singleton)

U can choose to make a class a singleton use annotation for that.

```
/**
 * @Singleton
 */
class Mailer
{
    //some code
}

$container = new Container();

$mailer = $container->get('Mailer');
$sameMailer = $container->get('Mailer');
```

###  Health Score

27

—

LowBetter than 47% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

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

Every ~214 days

Total

2

Last Release

3271d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/673625?v=4)[Jonathan Kowalski](/maintainers/jonathankowalski)[@jonathankowalski](https://github.com/jonathankowalski)

---

Top Contributors

[![jonathankowalski](https://avatars.githubusercontent.com/u/673625?v=4)](https://github.com/jonathankowalski "jonathankowalski (42 commits)")

---

Tags

dependency-injectionlazy

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/dconstructor-dconstructor/health.svg)

```
[![Health](https://phpackages.com/badges/dconstructor-dconstructor/health.svg)](https://phpackages.com/packages/dconstructor-dconstructor)
```

###  Alternatives

[symfony/dependency-injection

Allows you to standardize and centralize the way objects are constructed in your application

4.2k455.6M9.3k](/packages/symfony-dependency-injection)[illuminate/contracts

The Illuminate Contracts package.

706130.3M12.9k](/packages/illuminate-contracts)[illuminate/container

The Illuminate Container package.

31182.0M2.3k](/packages/illuminate-container)[ecotone/ecotone

Enterprise architecture layer for Laravel and Symfony — CQRS, Event Sourcing, Durable Workflows (Sagas, Orchestrators), Projections, and Outbox messaging via PHP attributes.

564576.7k47](/packages/ecotone-ecotone)[symfony/type-info

Extracts PHP types information.

20069.8M263](/packages/symfony-type-info)[civicrm/civicrm-core

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

751291.4k38](/packages/civicrm-civicrm-core)

PHPackages © 2026

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