matico / simple-php-di
SimplePHPDI
Installs: 4
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/matico/simple-php-di
Requires
- php: >=5.3.3
Requires (Dev)
- phpunit/phpunit: ~4.0
This package is auto-updated.
Last update: 2025-09-16 07:07:44 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