Using Laravel environments configuration via htaccess

This article describes how I did the configuration of my Laravel application with environment variables. I use the .htaccess to define hosts variables and use that in the application. For the sake of simplicity I’m defining production and local, but you can extend it with ‘staging’ and -or ‘test’ variables if you want.

Inside the .htaccess (in the public folder)

In the bootstrap/start.php add:

After that you can check with App::environment(‘local’) or App::environment(‘production’) to get the current environment in the application and -or blade templates.

For example if you need to load a different resource for local, you could use:

Leave a Reply

You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">