In my test cases, I try to change some of the environment variables to create better test case coverage.
Laravel by default, only support get environment variable by env($key, $default = null)
, I cannot change the variable.
The Illuminate\Support\Env
only supports get
, does not support set
.
Also, by default Laravel uses vlucas/phpdotenv
to managing the environment variable. Most of them are using ImmutableWriter
.
Is there any easy way to support dynamically changing environment variables are stored in ImmutableWriter
.
Again, the solution is no necessary to (and should not) be implemented in production for security reasons.