Conditionally Loading Service Providers in Laravel 5

In this tutorial, Matt Stauffer shows you an easy way of conditionally loading service providers.

Since Laravel 5 flattened a lot of the environment-specific structures, much of the configuration that was once stored in different config directories for each environment has now moved into .env files.

But one that can’t just live in .env is the environment-dependent loading of service providers.