PHP code example of ppokatilo / magic-injection-bundle

1. Go to this page and download the library: Download ppokatilo/magic-injection-bundle library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

ppokatilo / magic-injection-bundle example snippets


  class MyServiceB
  {
    /**
     * @MagicInjection(type="my_services")
     * @var \Service\MyServiceA
     */
    private $myServiceA;
  
    public function __construct()
    {
      assert($this->myServiceA === null);
    }
    
    public function foo()
    {
      $this->myServiceA->bar();
    }
  }