DEV Community

techdurjoy
techdurjoy

Posted on

How to Update .env File in Laravel Programmatically

There may be times when you want to dynamically change your .env file on the fly. This could be an admin functionality or perhaps you are creating an install script and want to be able to dynamically update the database data in your .env file.

It's actually pretty simple, just use this function to pass in the $key, $value that you want to change and it will dynamically update your environment variables.

How to Update .env File in Laravel Programmatically

Top comments (0)