M
M
Mokhirjon Naimov2016-06-27 18:00:28
Laravel
Mokhirjon Naimov, 2016-06-27 18:00:28

How to change APP_ENV (environment) values ​​in Laravel?

I would like to change the values ​​of APP_ENV when executing console commands to consolein place productionor local.


I know about .env file :)
I want to change these values ​​in code...

UPD:
I have event handlers for certain models, and when creating / updating these models, the handlers perform some processes. But! When I'm working through the console (i.e. using artisancommands I've created for specific purposes), these event handlers should not fire.
To solve this problem, I would like to use APP_ENV, that is, in event handlers, check APP_ENV != 'console'then process, if equal to consolethen skip processing. And console commandI would change APP_ENVto console.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Mokhirjon Naimov, 2016-06-27
@zvermafia

Found :)
putenv('APP_ENV=console');

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question