inject - PHP-DI annotation not working -


i have installed php-di 4.4 in new custom project using composer.im runing xampp localhost php 5.6.3 set netbeans php 5.4 on project. im new php-di, did use annotations in android projects cant seem make work here. code simple, im testing out injection see how works, here code:

// composer autoload require_once __dir__ . '/vendor/autoload.php';  // injection entry point $builder = new di\containerbuilder(); $container = $builder->build();  class classa {     public function methoda()     {         echo 'methoda';     } } class classb {     /**      * @inject      * @var classa      */     public $param;      public function methodb()     {         $this->param->methoda();     } }  $b = new classb(); $b->methodb(); 

this error get: call member function methoda() on null in d:\projects\profi\test.php on line 27

it's basic implementation don't understand why not inject.

thank in advance.

php-di cannot magically intercept when create b (to inject in b). have create b using php-di:

$b = $container->get('classb'); $b->methodb(); 

Comments