title: How to access Laravel Singletons in a class?
body: <p>I have registered a singleton in a service provider like so:</p>
  
  <pre><code>$this-&gt;app-&gt;singleton(MyClass::class);
  </code></pre>
  
  <p>This can normally be accessed by simply stating it in the parameters like so:</p>
  
  <pre><code>class FooController extends Controller
  {
      public function index(MyClass $myClass)
      {
          //...
      }
  }
  </code></pre>
  
  <p>However I cannot seem to be able to access this singleton in other custom classes (i.e. non controller classes).  (<a href="https://laravel.com/docs/5.2/container#resolving" rel="noreferrer">https://laravel.com/docs/5.2/container#resolving</a>)</p>
  
  <p>For example like here:</p>
  
  <pre><code>class Bar {
     private $myClass;
     private $a;
     private $b;
  
     public function __construct($a, $b) {
        $this-&gt;a = $a;
        $this-&gt;b = $b;
        $this-&gt;myClass = ... // TODO: get singleton
     }
  }
  </code></pre>
  
  <p>How do I do this?</p>
  
  <p>Note that I will be creating multiple instances of <code>Bar</code>.</p>