Samuel Dauzon
Samuel Dauzon

Reputation: 11334

Lumen environments definition

I have used Lumen (Laravel based framework) to design my API.

I must manage two environments (production, local). I tried to put these lines in my bootstrap/app.php file :

$env = $app->detectEnvironment(array(
    'local'         => array('my-system'),
    'production'    => array('prod-system'),
));

But, when I try to execute php artisan serve it gives me the following error :

Call to undefined method Laravel\Lumen\Application::detectEnvironment()

How can I define my environments in Lumen ?

Upvotes: 1

Views: 2884

Answers (1)

edgji
edgji

Reputation: 183

If you're looking to define an environment conditionally based on hostname the following should work:

$env = str_is('production-hostname', gethostname()) ? 'production' : 'local';
putenv("APP_ENV=$env");

In lumen this should go in your bootstrap/app.php file.

Upvotes: 0

Related Questions