How to change the value of APP_ENV (environment) in Laravel?

I would like to change the value of APP_ENV when you execute a console command on the console to the place of production or local.


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



UPD:
I have event handlers for certain models, and create/update these models handlers perform some processes. But! When I'm working through the console (that is, use the artisan command which I created for certain purposes), these event handlers should not work together.

To solve this problem, I'd like to use APP_ENV, that is, in the event handlers to check APP_ENV != 'console' to handle, if set to console, then skip the processing. And the console command would change APP_ENV to console.
July 8th 19 at 11:43
1 answer
July 8th 19 at 11:45
Solution
Found :)
putenv('APP_ENV=console');

Find more questions by tags LaravelPHP