title: How to set .env values in laravel programmatically on the fly
body: <p>I have a custom CMS that I am writing from scratch in Laravel and want to set <code>env</code> values i.e. database details, mailer details, general configuration, etc from controller once the user sets up and want to give user the flexibility to change them on the go using the GUI that I am making.</p>
  
  <p>So my question is how do I write the values received from user to the <code>.env</code> file as an when I need from the controller.</p>
  
  <p>And is it a good idea to build the <code>.env</code> file on the go or is there any other way around it?</p>
  
  <p>Thanks in advance.</p>