Is Laravel 5.1 App:singleton not working properly?
<p>Given this code, placed in the default file routes.php in Laravel 5.1:</p>

<pre><code>    \App::singleton('CatalogsService', function(){
            return new CatalogsService;
        });   

Route::group(['prefix' =&gt; 'catalogs'], function() {
    Route::get('statesmx', function (){       

        return var_dump(app('CatalogsService'));
    });

    Route::get('statesmx2', function() {
        return var_dump(app('CatalogsService'));
    });

    Route::get('statesmx3', function() {
        return var_dump(app('CatalogsService'));
    });

});
</code></pre>

<p>Why am I getting a different instance of CatalogsService when navigating to the 3 defined routes? </p>

<p>localhost/catalogs/statesmx dumps:</p>

<pre><code>object(App\Services\Common\CatalogsService)[152]
</code></pre>

<p><code>localhost/catalogs/statesmx2</code> dumps:</p>

<pre><code>object(App\Services\Common\CatalogsService)[153]
</code></pre>

<p><code>localhost/catalogs/statesmx3</code> dumps:</p>

<pre><code>object(App\Services\Common\CatalogsService)[154]
</code></pre>

<p>I was expecting to get the same Object Reference Id.</p>

<p>The only way to get the same reference is by adding the next code before the <code>Route::group....</code></p>

<pre><code>app('CatalogsService');
</code></pre>

<p>when I do it the 3 routes dump the same object reference:</p>

<pre><code>object(App\Services\Common\CatalogsService)[106]
</code></pre>

<p>I don't get it why is this happening. For me it looks Laravel Singleton is not working properly unless there's something I'm missing about the way a Singleton in Laravel works. </p>

<p>Thank you in advance for any help or hint on this matter.</p>

<p>PD: I'm new to Laravel.</p>