PHPackages                             mikemix/mxdi-module - 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. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. mikemix/mxdi-module

AbandonedLibrary[Parsing &amp; Serialization](/categories/parsing)

mikemix/mxdi-module
===================

Configure dependency injection in ZF2 using annotations/YAML

3.1.5(10y ago)3227MITPHPPHP &gt;=5.5.0

Since Jun 16Pushed 10y ago1 watchersCompare

[ Source](https://github.com/mikemix/mxdiModule)[ Packagist](https://packagist.org/packages/mikemix/mxdi-module)[ Docs](https://github.com/mikemix/mxdiModule)[ RSS](/packages/mikemix-mxdi-module/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (8)Versions (29)Used By (0)

mxdiModule
==========

[](#mxdimodule)

[![Build Status](https://camo.githubusercontent.com/3f7adee547e76f2fb4cdee250fbe7b756ccaa33db72b725158932945b533084a/68747470733a2f2f7472617669732d63692e6f72672f6d696b656d69782f6d7864694d6f64756c652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/mikemix/mxdiModule) [![Build Status](https://camo.githubusercontent.com/7e7747ded4792eb2129e2807311b3a93524146d902d9520a75b59d806307ac04/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6d696b656d69782f6d7864694d6f64756c652f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/mikemix/mxdiModule/build-status/master) [![Scrutinizer Code Quality](https://camo.githubusercontent.com/2bc383662e40cc297814d1561f0715c1c0a1188011abfd1590bee33d7df0bbdb/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6d696b656d69782f6d7864694d6f64756c652f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/mikemix/mxdiModule/?branch=master) [![Code Coverage](https://camo.githubusercontent.com/4c4badd8f8ca8eda03cdac9b7481104f83e6de0e1cccd342af538ba894453d3f/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6d696b656d69782f6d7864694d6f64756c652f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/mikemix/mxdiModule/?branch=master) [![Dependency Status](https://camo.githubusercontent.com/357f3ac0de5263a52b1f3df6fc5d3ccef825ecc1ed57b038ae2ba2ea3979cdaa/68747470733a2f2f7777772e76657273696f6e6579652e636f6d2f757365722f70726f6a656374732f3535383262666638333633383631303031353030303235622f62616467652e7376673f7374796c653d666c6174)](https://www.versioneye.com/user/projects/5582bff8363861001500025b) [![Latest Stable Version](https://camo.githubusercontent.com/8cca9e9b482a95cfc93d5485b423f9198dd58e53eb3836da998176377bb50440/68747470733a2f2f706f7365722e707567782e6f72672f6d696b656d69782f6d7864692d6d6f64756c652f762f737461626c65)](https://packagist.org/packages/mikemix/mxdi-module) [![Total Downloads](https://camo.githubusercontent.com/ac040ca662f49769c7451f36ec710137337a7afbd47f9b6e447a24b59366b2b4/68747470733a2f2f706f7365722e707567782e6f72672f6d696b656d69782f6d7864692d6d6f64756c652f646f776e6c6f616473)](https://packagist.org/packages/mikemix/mxdi-module) [![License](https://camo.githubusercontent.com/c46f21d9d832e3b17d8db27016d10c6fdcabe91a0ba31256330c7c6679c7a1e9/68747470733a2f2f706f7365722e707567782e6f72672f6d696b656d69782f6d7864692d6d6f64756c652f6c6963656e7365)](https://packagist.org/packages/mikemix/mxdi-module)

Configure dependency injection in Zend Framework 2 using annotations/yaml/xml.

Idea based on the [JMSDiExtraBundle](https://github.com/schmittjoh/JMSDiExtraBundle) for the Symfony2 project.

1. [Installation](#installation)
2. [Changing mapping driver](#changing-mapping-driver)
3. [Important notes](#important-notes)
4. [Caching](#caching)
5. [Debugging](#debugging)
6. [Console commands](#console-commands)

### Installation

[](#installation)

1. Install with Composer: `composer require mikemix/mxdi-module:~3.0` (rules of [semantic versioning](http://semver.org) apply).
2. Enable the module via ZF2 config in `appliation.config.php` under `modules` key:

    ```
    return [
        //
        //
        'modules' => [
            'mxdiModule',
            // other modules
        ],
        //
        //
    ];
    ```

    This will enable the module and register the Abstract Factory in the ZF2's Service Manager.
3. Copy the global config file `cp vendor/mikemix/mxdi-module/resources/mxdimodule.global.php.dist config/autoload/mxdimodule.global.php` if you want to override the default mapping driver.
4. Copy the local config file `cp vendor/mikemix/mxdi-module/resources/mxdimodule.local.php.dist config/autoload/mxdimodule.local.php` if you want to override other settings, like caching etc.

### Changing mapping driver

[](#changing-mapping-driver)

The default mapping driver is `AnnotationExtractor` as source of mapping information for the module. You can change it however to other. Available extractors are:

- `AnnotationExtractor` (default) which uses annotations inside your classes. See the [Annotation docs](docs/Annotations.md) for annotations reference and examples.
- `YamlExtractor` which uses a yml file. See the [YAML](docs/Yaml.md) docs for examples.
- `XmlExtractor` which uses a xml file. See the [XML](docs/Xml.md) docs for examples.

There's **no difference** between choosing annotation driver or YAML or XML driver, because the mapping information in the end is converted to **plain php** and stored **inside the cache**.

### Important notes

[](#important-notes)

**Remember**, the requested service must not be registered in the [Service Manager](http://framework.zend.com/manual/2.3/en/modules/zend.service-manager.intro.html). If you register it as factory or invokable, it won't go through the Abstract Factory and won't get injected. By the way, this allows you to create custom factory for the service in mention.

To speed up locate time you can request the service through the DiFactory invokable, for example:

```
/** @var \mxdiModule\Service\DiFactory @factory */
$factory = $this->getServiceLocator()->get(\mxdiModule\Service\DiFactory::class);

/** @var \YourApplication\Service\SomeService $service */
$service = $factory(\YourApplication\Service\SomeService::class);
```

### Caching

[](#caching)

Parsing mapping sources is very heavy. You *should* enable the cache on production servers.

You can set up caching easily with any custom or pre-existing ZF2 cache adapter. In the `config/autoload/mxdimodule.local.php` override the `cache_adapter` and `cache_options` keys for your needs. You can find more information about available out-of-the-box adapters at the [ZF2 docs site](http://framework.zend.com/manual/current/en/modules/zend.cache.storage.adapter.html).

### Debugging

[](#debugging)

If you get *ServiceNotCreated* exception most probably one of your injections is not registered in the ZF2's Service Manager. In the exception stack you will see some more detailed information. For instance look for *CannotGetValue*exceptions.

### Console commands

[](#console-commands)

- Clear generated proxy files: `php public/index.php mxdimodule proxy clear`

    Clear all generated proxy files from the proxy dir
- Clear annotation parsing cache: `php public/index.php mxdimodule cache clear []`

    Flush whole cache or only of a given service

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity69

Established project with proven stability

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 ~10 days

Recently: every ~62 days

Total

28

Last Release

3710d ago

Major Versions

0.4 → 1.02015-06-17

1.2 → 2.02015-06-22

2.4 → 3.02015-07-02

### Community

Maintainers

![](https://www.gravatar.com/avatar/7f120faf0f68744fbc357d36e55bb78ec43fa3c2c81eb70f476893540ef1621f?d=identicon)[mikemix](/maintainers/mikemix)

---

Tags

dependency-injectionyamlannotationsdiZendFrameworkzf2

### Embed Badge

![Health badge](/badges/mikemix-mxdi-module/health.svg)

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

###  Alternatives

[jms/metadata

Class/method/property metadata management in PHP

1.8k152.8M88](/packages/jms-metadata)[spatie/yaml-front-matter

A to the point yaml front matter parser

3411.8M68](/packages/spatie-yaml-front-matter)[pragmarx/yaml

Load your Laravel config files using yaml

1152.8M29](/packages/pragmarx-yaml)[stroker/cache

Provides a full page cache solution for Laminas

6444.7k](/packages/stroker-cache)[hrevert/ht-img-module

Image manipulation module for Zend Framework 2

1829.6k2](/packages/hrevert-ht-img-module)[sspooky13/yaml-standards

Standards for yaml files

11518.3k3](/packages/sspooky13-yaml-standards)

PHPackages © 2026

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