You really don't want to be altering config files from your http controller. If you need dynamic configuration you will be better with a database table.
Actually it's not possible to describe details why i need this. i don't want to use database table. Can you give me some solution how to modify Config folder database.php file. @ohffs
You'd have to make the files/folder writeable by your webserver (like you do for the storage/ directory) then use things like fopen()/fwrite() etc - but this is a really, really bad idea and very prone to errors and problems. I can't emphasise enough what a bad idea this is.
Which will apply for the request, but as @ohffs suggests above, I wouldn't do it. If a value is changing at runtime, it probably doesn't belong in a static configuration value.
Why wouldn't you just set them in the config file itself, then? Each time you need to change the values, update the config file, then push and redeploy the config. Or, as @ohffs said, shift the (I presume) user-modifiable values to the database.
@ohffs@deringer let me expose and example I think it could be useful to "dinamically/programatically" modify config file:
Command line execution, something like artisan custom commands.
For example I'm tired every time I've to install a new laravel service provider from a package, everytime we do the same adding a provider to providers array i config/app file. Imagine how could would be:
$ php artisan provider:add "\App\MyProvider"
So anyone now have a recommendation of hot to easily modify Laravel config files programatically?
@acacha doing it from the commandline is a different prospect though, surely? If you wanted you could just rm -fr all the config files. Which isn't something you want to happen via your website, usually ;-) Oddly enough, for your specific example there was a tool mentioned recently to speed up adding providers : https://github.com/remoblaser/lazy-artisan