PHPackages                             hatem-azzouzi/z-di - 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. hatem-azzouzi/z-di

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

hatem-azzouzi/z-di
==================

Easy minimalist dependenncy injection package

0.1.0(2y ago)012MITPHPPHP &gt;=7.2.0

Since Mar 18Pushed 10mo ago1 watchersCompare

[ Source](https://github.com/hatem-azzouzi/z-di)[ Packagist](https://packagist.org/packages/hatem-azzouzi/z-di)[ RSS](/packages/hatem-azzouzi-z-di/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)DependenciesVersions (2)Used By (0)

Z-DI
====

[](#z-di)

Contents of this file
---------------------

[](#contents-of-this-file)

- [Introduction](#introduction)
- [Requirements](#requirements)
- [Installation](#installation)
- [Usage](#usage)
    - [Dependency Injection](#dependency-injection)
    - [Lazy loading](#lazy-loading)
    - [Eager loading](#eager-loading)
    - [Recursion](#recursion)
- [Contributing](#contributing)
- [Maintainers](#maintainers)
- [License](#license)

Introduction
------------

[](#introduction)

Z-DI is intended for educational purposes for beginners looking to learn more skills and master PHP. Very lightweight and minimalist DI ([Dependency Injection](https://en.wikipedia.org/wiki/Dependency_injection)) package with lazy loading and recursive configuration capabilities.

Requirements
------------

[](#requirements)

There is no requirement to install this package other than PHP. PHP &gt;=7.2.0 is recommended. PHP 8.3 is highly recommended.

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

[](#installation)

Use the dependency manager [composer](https://getcomposer.org/download/) to install Z-DI.

```
composer require hatem-azzouzi/z-di
```

Usage
-----

[](#usage)

### Dependency Injection (DI)

[](#dependency-injection-di)

In software engineering, DI is a programming technique to inject a resource or a service (dependency) into a client on which it depends on to function. Client does not have to create nor to instantiate the resource or know how it is created.

Below is an example of a configuration file to create entry points for 2 services and a client. In this example, we inject the Email service into the Client. You can also try the Text service. Both services implement the same interface IMessage.

```
