0

Trying to set the environment variable from commandline like

php artisan serve --env=someenv

But a var_dump(App::environment()) outputs string 'production' (length=10).

Shouldn't it be someenv ?

Laurence
  • 58,936
  • 21
  • 171
  • 212
M T
  • 4,099
  • 4
  • 21
  • 27

2 Answers2

2

This environment you set on php artisan seve is just for that particular command, running on cli.

Note that this is not you application running, just a webserver, provided by PHP so you don't need to install a full apache or nginx to test your application.

Your web application will run under a different environment and you still need to provide a correct environment adding it to your bootstrap/start.php file:

$env = $app->detectEnvironment(array(

    'local' => array('localhost', '127.0.0.1', 'example.com'),

));
Antonio Carlos Ribeiro
  • 86,191
  • 22
  • 213
  • 204
0

Laravel 5 can use a .env file in your installation base directory to determine your environment. For example, to set the current environment as the „local“ one, create a file .env with

APP_ENV = local

Please see another answer for more details on this mechanism.

Community
  • 1
  • 1
Olav
  • 1,602
  • 2
  • 16
  • 21