title: PHP dependency injection - difference between a container, a controller or a factory
body: <p>I still cannot tell the difference between a container, a controller or a factory. For instance, the code below, should it be considered as a container, a controller or a factory?</p>
  
  <p>How should it be like if it is a container in this case?</p>
  
  <pre><code>namespace ioc
  {
      class LoggerContainer
      {
          use \Snippets;
  
          /*
           * Set props.
           */
          protected $Database;
          public $Logger;
  
          /**
           * Construct data.
           */ 
          public function __construct($Database) 
          {
              // Set DI.
              $this-&gt;Database = $Database;
  
              // Run private method.
              $this-&gt;getLogger();
          }
  
          /**
           * Set a new class (instantiate the class) as the return result.
           */
          private function getLogger()
          {
              $signature = AUTHENTICATED_USER_SIGNATURE;
              $this-&gt;Logger = new \core\model\Logger($this-&gt;Database);
  
              if($_REQUEST['url'] === 'backoffice')
              {
                  return $this-&gt;Logger-&gt;setLogger($signature)-&gt;addCategory()-&gt;addSomething();
              }
              else
              {
                  return $this-&gt;Logger-&gt;setLogger($signature)-&gt;removeSomething();
              }
  
          }
      }
  }
  </code></pre>