Confused - AppServiceProvider.php versus app.php

user391986 picture user391986 · May 21, 2015 · Viewed 7.2k times · Source

Where do I specify my bindings exactly? It seems I can do it in either of these files.

config/app.php Inside of 'providers' =>

app/Providers/AppServiceProvider.php Inside of register()

Answer

Amelia picture Amelia · May 21, 2015

The service providers array is loaded via config/app.php. This is the only actual place that providers are registered, and is where you should put Service Providers.

AppServiceProvider is for Laravel-specific services that you've overridden (or actually specified), such as the Illuminate\Contracts\Auth\Registrar, The HTTP/Console Kernels, and anything you wish to override in Laravel. This is a single service provider, that registers container bindings that you specify.

Really, you could load anything you want here, but there's a bunch of ready-to-go service providers in the app/Providers directory for you so you don't have to go and make one yourself.