Skip to content
This repository has been archived by the owner on Sep 16, 2020. It is now read-only.

rustygoldcoin/firedi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

95 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FireDI - PHP Dependency Injection (DI)

A light weight PHP dependency injection library featuring automatic, constructor based, dependency resolution. When you need a new object from a class definition just simply ask for it. Any dependencies type hinted on the constructor will be resolved and injected before the class is instantiated into an object.

The whole reason for FireDI to exist is to manage and resolve dependencies for you. The Dependency Injection design pattern provides you with the ability to decouple class dependencies across your entire application by resolving these dependencies for you.

Features:

  • Automatic constructor based dependency resolution. Dependencies can be resolved automatically for you by type hinting the object you expect to be injected in the constructor.
  • Circular dependency detection.
  • Automatic object caching. So that when you ask for an object more than once, it is provided without having to run through the process of dependency resolution.
  • The ability to define your own dependencies within the DI container. This works great for mocking dependencies within unit/integration tests.
  • Ability to define your own dependencies for the situation where you need to get a class with specific dependencies that are not defined within the container.

Documentation

https://ua1.us/projects/firedi/

Install FireDI Using Composer

composer require ua1-labs/firedi

Getting Started

Let's say you would like to get an instantiated object MyClass1. Well MyClass1 requires that you pass into its constructor MyClass2. FireDI will resolve MyClass2 and automatically inject it into MyClass1 and return the instantiated object MyClass1 to you.

MyClass1

class MyClass1
{
    public function __construct(MyClass2 $myClass2) {}
}

MyClass2

class MyClass2 {}

FireDI In Action

// instantiate firedi
$firedi = new UA1Labs\Fire\Di();

// obtain an object and have it's dependencies resolved for you
$myClass1 = $firedi->get('MyClass1');

About

FireDI - PHP Dependency Injection (DI)

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages