Use of service providers within controllers in Laravel 5.2
<p>As for the title I've googled about two hours searching for a efficient answer and read repeatedly the official documentation, but without any step further, considering I'm relatively new to the framework. The doubt arise while searching for a correct way to share some code between controllers and i stumbled in service providers, so:</p>
<ol>
<li><p>I've created say a <code>MyCustomServiceProvider</code>;</p>
</li>
<li><p>I've added it to the <code>providers</code> and <code>aliases</code> arrays within the <code>app.php</code> file;</p>
</li>
<li><p>finally I've created a custom helpers class and registered it like:</p>
<pre><code>class MyCustomServiceProvider extends ServiceProvider
{
    public function boot()
    {
        //
    }

    public function register()
    {
        $this-&gt;app-&gt;bind('App\Helpers\Commander', function(){

            return new Commander();

        });
    }
}
</code></pre>
</li>
</ol>
<p>So far, however, if I use that custom class within a controller I necessarily need to add the path to it through the <code>use</code> statement:</p>
<pre><code>use App\Helpers\Commander;
</code></pre>
<p>otherwise I get a nice class not found exception and obviously my controller does not his job.<br>
I suspect there's something which escapes to me on service providers! :-)</p>