matico/simple-php-di

SimplePHPDI

Maintainers

Package info

github.com/mactiencong/SimplePHPDI

pkg:composer/matico/simple-php-di

Statistics

Installs: 4

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

dev-master 2019-03-15 16:48 UTC

This package is auto-updated.

Last update: 2026-02-16 08:12:31 UTC


README

Build Status

The simple Dependency Injection lib for PHP (5.3.x ~)

How to work

  1. Inject annotations
  • @Inject Inject a object instance normaly
/**
 * 
 * @author matico
 * @Inject Address
 * @Inject Skill
 *
 */
class Developer {
}
  • @InjectSingleton Inject a singleton object
/**
 * 
 * @author matico
 * @InjectSingleton Country
 */
class Address {
}
$maticoDeveloper = DI::get('Developer', array('name'=>'matico'));
$maticoInfo = $maticoDeveloper->info();
$congmtDeveloper = DI::get('Developer', array('name'=>'congmt'));
$congmtInfo= $congmtDeveloper->info();
$this->assertSame('matico-VN-PHP', $maticoInfo);
$this->assertSame('congmt-VN-PHP', $congmtInfo);

View example detail in testcases