How to Use Local Environment as Default in Laravel Artisan CLI

I have to say, I absolutely LOVE Laravel – everything about it.

One of my favorite features is the ability to separate your app into local/production versions.

I use a lot of packages for development, that I just don’t need on my production version of the app. How do I resolve this? By using two different environments w/ different App.php configs. Read my tutorial on this here.

You might find that this only works for your app when running it in the browser. Here’s how to make sure that the local environment is ALSO set for command-line e.g. Artisan and Tinker.

One option of course is to do:

But who wants to write –env=local after EVERY artisan command? I am a pragmatist and believe in using technology to my advantage. This is great when needing to switch back and forth for a minute, but when doing it all the time you need an alternative.

next add “PatrickPC” to bootstrap/start.php

Now artisan should run w/ local environment as default when on this machine, let’s test it:

Got questions? Leave a comment!

How to setup Local and Production environments on Laravel

One great feature of Laravel is how easy it is to setup local and dev environments.

Why would you want separate environments?

  • Require separate packages for dev, and production.
  • Less bloat / potential for errors on production.
  • Turn off debug on production.
  • Special config options for local vs production.
  • etc…

Next we simply create a new folder at : App/config/local/

If you create a App.php file -this file will override the global App.php in the parent directory while working in the local environment. So you can add different providers/facades to this local version and not mess up the production version.