title: Laravel setter injection
body: <p>How can i use setter dependency injection with Laravel's service container to have automatic dependency resolution?</p>
  
  <p>Here's an example:</p>
  
  <pre><code>class Test
  {
      (...)
  
      public function setMailer(Mailer $mailer) 
      {
          $this-&gt;mailer = $mailer;
      }
  
      (...)
  
      function sendEmail()
      {
          $this-&gt;mailer-&gt;send(new Email('john.doe@example.com'));
      }
  }
  </code></pre>
  
  <p>How can i ensure that, when <code>sendEmail()</code> is called, the mailer dependency is statisfied? How can i leverage Laravel's service container to achieve this?</p>
  
  <p>Thanks in advance.</p>