matico / simple-php-di
SimplePHPDI
dev-master
2019-03-15 16:48 UTC
Requires
- php: >=5.3.3
Requires (Dev)
- phpunit/phpunit: ~4.0
This package is auto-updated.
Last update: 2025-04-16 06:23:06 UTC
README
The simple Dependency Injection lib for PHP (5.3.x ~)
How to work
- 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