Edit your Laravel .env file

Submitted by ramesh - 8 years ago

The following example shows an controller with a method, in which we change some values from the .env. Make sure, the entries you want to change, really exist in your .env. https://github.com/Brotzka/laravel-dotenv-editor

namespace App\Http\Controllers;

use Brotzka\DotenvEditor\DotenvEditor;

class EnvController extends Controller
{
    public function test(){
        $env = new DotenvEditor();

        $env->changeEnv([
            'TEST_ENTRY1'   => 'one_new_value',
            'TEST_ENTRY2'   => $anotherValue,
        ]);
    }
}