0

I'm trying to get environment detection to work, so that I can use the .env.local.php file and all the other goodies, but somehow I cannot get it to detect the right environment.

I have added bootstrap/environment.php

<?php

$env = $app->detectEnvironment(array(

    'local' => array('mylocalmachinename') 

)); 

But when I php artisan env, I always get production instead of local.

Anyone know what the problem is?

Marcin Nabiałek
  • 109,655
  • 42
  • 258
  • 291
Tino
  • 3,340
  • 5
  • 44
  • 74
  • Are you sure, that the machine name is really the same? Does the case of letters match? – Mārtiņš Briedis Nov 05 '14 at 12:04
  • 1
    possible duplicate of [What's the correct way to set ENV variables in Laravel 5?](http://stackoverflow.com/questions/26346299/whats-the-correct-way-to-set-env-variables-in-laravel-5) – Marcin Nabiałek Nov 05 '14 at 12:06

1 Answers1

3

Environment detection has changed in Laravel5.

You now put a .env file in the project root

APP_ENV=local

Then on another computer - you might do

APP_ENV=staging

You can then add additional environmental items - i.e.

APP_ENV=local
APP_KEY=SomeRandomString
DB_USERNAME=homestead
DB_PASSWORD=homestead
Laurence
  • 58,936
  • 21
  • 171
  • 212
  • 1
    Laravel 5 is still under development. Its not even in Beta yet at the time of this post. Once it is ready, the docs will be updated – Laurence Nov 05 '14 at 12:46
  • Quick note about .env: This file is different for every environment and it is .gitignored by default. You should recreate it (or ftp it) in your production environment with the correct values! – igaster Nov 18 '14 at 11:03
  • @Laurence what is if else function to detect environment? – horse Feb 11 '17 at 12:58