How to set up a local environment in Laravel 4

I just want to set up a local environment in Laravel 4.

In bootstrap/start.php , I have:

 $env = $app->detectEnvironment(array( 'local' => ['laravel.dev', ''], )); 

I tried changing the local development index in the array, but nothing works. I tried some tips on this page: http://laravel.com/docs/configuration ... nothing.

I use artisan in a console that always tells me:

 ************************************** * Application In Production! * ************************************** Do you really wish to run this command? 

What can I do to teach Lara that I am in the local environment?

+6
source share
3 answers

You can try this (in bootstrap/start.php ):

 $env = $app->detectEnvironment(array( 'local' => ['*.dev', gethostname()], 'production' => ['*.com', '*.net', '*.org'] )); 

It is also possible:

 $env = $app->detectEnvironment(function() { return gethostname() == 'your local machine name' ? 'local' : 'production'; }); 
+37
source

Following @The Alpha's excellent answer - here is a small modification using an array to check local machines (when you are working from more than one place):

 $env = $app->detectEnvironment(function() { return in_array( gethostname(), [ 'first local machine name', 'second local machine name' ] ) ? 'local' : 'production'; }); 
+3
source
 $env = $app->detectEnvironment(function() { $substr = substr(gethostname(), "-4"); return ($substr == ".com" || $substr == ".net" || $substr == ".org") ? 'production' : 'local'; }); 
0
source

Source: https://habr.com/ru/post/970542/


All Articles