PHP Classes
elePHPant
Icontem

PHP Dependency Injection Container: Autoload dependent objects accessing variables

Recommend this page to a friend!
  Info   View files Example   View files View files (10)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog (2)    
Last Updated Ratings Unique User Downloads Download Rankings
2015-10-17 (1 year ago) RSS 2.0 feedNot enough user ratingsTotal: 333 This week: 2All time: 6,749 This week: 591Up
Version License PHP version Categories
pdi 1.0GNU General Publi...7.0Design Patterns, PHP 7
Description Author

This class can autoload dependent objects accessing variables.

It provides a dependency injection base class that when it is accessed a given inexistent variable it will automatically load a class with a name based on the variable name and assign it an object of that class.

The class can use a given autoloader to load the dependency class in case it is not yet loaded.

Innovation Award
PHP Programming Innovation award nominee
October 2015
Number 6


Prize: SourceGuarding PHP encoder tool
Dependency injection is a design pattern that allows to configure the behavior of an object using external objects.

This package implements a dependency injection container that autoloads external dependency objects dynamically when certain variables of the dependent object are accessed for the first time.

Manuel Lemos
Picture of Samuel Adeshina
  Performance   Level  
Name: Samuel Adeshina <contact>
Classes: 19 packages by
Country: Nigeria Nigeria
Innovation award
Innovation award
Nominee: 7x

Winner: 1x

Details
CONFUSED??

Don't know which of Injector.php or Injector_5.php
to choose from?

Injector.php has complete support for PHP 7, it's
possible you've not heard of PHP 7 yet or you haven't
upgraded (which BTW, you must have a very good reason for)
So the script has been rewritten (Injector_5.php)
with support for the already 'legacy' versions of php.

I recommend leaving the import.php script as is, if you
are in a development environment, but please try as much as
possible to change exit() to some proper logic you use
for error reporting in your production environment.

Enjoy!
Samuel Adeshina
  Files folder image Files  
File Role Description
Files folder imageexample (4 files)
Files folder imagesrc (4 files)
Accessible without login Plain text file composer.json Data Required Dependencies
Accessible without login Plain text file README.md Data Read Me

  Files folder image Files  /  example  
File Role Description
  Plain text file Dependee.php Class [Example]Dependee Class
  Plain text file Depender.php Class [Example]Depender Class
  Accessible without login Plain text file index.php Example [Example] Index
  Accessible without login Plain text file test.php Example run this file without an autoloader

  Files folder image Files  /  src  
File Role Description
  Accessible without login Plain text file import.php Aux. Use in development only
  Plain text file Injector.php Class Main Class. PHP 7 compatible
  Plain text file Injector_5.php Class Main Class. PHP 7 Incompatible
  Accessible without login Plain text file readme.txt Doc. Read Me

 Version Control Unique User Downloads Download Rankings  
 100%
Total:333
This week:2
All time:6,749
This week:591Up