title: Do I need to define a container inside a class for dependency injection?
body: <p>I am learning Auraphp Di, and I want to write sample code. Suppose I have these files:</p>
  
  <p>public/index.php:</p>
  
  <pre><code>use Aura\Di\ContainerBuilder;
  use MyPackage\Component\Authentication\AuthenticateFlow;
  
  require_once dirname(__DIR__) . '/vendor/autoload.php';
  
  $builder = new ContainerBuilder();
  $di = $builder-&gt;newInstance();
  
  $di-&gt;set('authenticateFlow', $di-&gt;lazyNew(AuthenticateFlow::class));
  
  $authenticateFlow = $di-&gt;get('authenticateFlow');
  
  $authenticateFlow-&gt;showName('Belkin');
  </code></pre>
  
  <p>/src/Components/Authentication/AuthenticationFlow.php:</p>
  
  <pre><code>namespace MyPackage\Components\Authentication;
  
  class AuthenticationFlow
  {
      public function showName($name)
      {
          echo $name;
      }
  }
  </code></pre>
  
  <p>This is working fine. Now suppose I have another class (/src/Components/Authentication/Filter.php), which has a method called filterInput:</p>
  
  <pre><code>namespace MyPackage\Components\Authentication;
  
  class Filter
  {
      public function filterInput($input)
      {
          return htmlspecialchars($input);
      }
  }
  </code></pre>
  
  <p>How can I inject Filter to AuthenticationFlow, to use filterInput() method? I wanna have something like this in AuthenticationFlow::showName():</p>
  
  <pre><code>echo $this-&gt;filter-&gt;filterInput($name);
  </code></pre>
  
  <p>I am aware that I need to inject Filter class in AuthenticationFlow constructor, but I don't know if I can use the container built in the index.php or not.
  If I need to create another container in AuthenticationFlow, how index.php would be aware of it?</p>