UA1 Labs

FireDI – Getting Started

joshualjohnson profile image Joshua Johnson Originally published at ua1.us on ・1 min read

In this tutorial, you will learn how to get started with FireDI! A quick recap, FireDI is a PHP dependency injection library that makes it simple to help you manage dependencies within your classes. If you haven’t quite decided whether you should be using FireDI or not, checkout our page about When Should I Use Dependency Injection?.

Installing FireDI

Installing FireDI is so easy by simply using composer.

composer require ua1-labs/firedi

That’s It! It’s included in your project and ready to go!

Using FireDI

FireDI is simple to use and has a simple API.

$fireDi = new UA1Labs\Fire\Di();
$myClass = $fireDi->get('myClass');

Hint: When integrating FireDI into your project, you may want to consider implementing it as a singleton. Doing so will allow you to simply pull it into what ever part of the code you want. This way you can take advantage of it’s built in object caching. Plus, whenever you instantiate an object using a FireDI container, that container will keep keep track of all dependencies and be much faster in resolving them as your application grows.

Note: It is much more efficient to only use one instance of FireDI within your project.

The post FireDI – Getting Started appeared first on UA1 Labs.

Posted on by:

joshualjohnson profile

Joshua Johnson


a developer looking to share cool things.

UA1 Labs

The spark of imagination, matched so eloquently with the power to create anything, is when innovative software is born.


Editor guide