Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set local environment in Laravel 4

I just want to set the local environment into Laravel 4.

In bootstrap/start.php I have:

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

I tried change local to development index in array, but nothing works. I tried some tips of this page: http://laravel.com/docs/configuration... nothing.

I'm using artisan in console, that always say me:

**************************************
*     Application In Production!     *
**************************************

Do you really wish to run this command?

What I might do to teach Lara that I'm on local environment?

like image 500
Godô Avatar asked Jun 08 '14 16:06

Godô


People also ask

Where is .env file in Laravel?

In a fresh Laravel installation, the root directory of your application will contain a . env. example file that defines many common environment variables.

Where is config PHP in Laravel?

All of the configuration files for the Laravel framework are stored in the app/config directory. Each option in every file is documented, so feel free to look through the files and get familiar with the options available to you.


2 Answers

You may try this (In bootstrap/start.php file):

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

Also this is possible:

$env = $app->detectEnvironment(function() {

    return gethostname() == 'your local machine name' ? 'local' : 'production';
});
like image 80
The Alpha Avatar answered Sep 22 '22 19:09

The Alpha


Following on from @The Alpha's great answer - here's a slight modification using array to check for local machines (when you work from more than one location):

$env = $app->detectEnvironment(function() {

    return in_array(
            gethostname(), 
            [
                'first local machine name', 
                'second local machine name'
            ]
        ) ? 
        'local' : 
        'production';

});
like image 45
Sebastian Sulinski Avatar answered Sep 20 '22 19:09

Sebastian Sulinski