public static function updateEnvSetting(array $settings, $path = null)
    {
        if (empty($path)) {
            $path = base_path('.env');
        }

        if (file_exists($path)) {
            $subject = file_get_contents($path);

            foreach ($settings as $key => $value) {
                // Uncomment if any of keys are commented out by default.
                $subject = str_replace(['#' . $key, '##$key'], $key, $subject);
            }

            // Update uncommented keys.
            file_put_contents($path, $subject);

            foreach ($settings as $key => $value) {
                /**
                 * Using a new instance of dotenv to get the
                 * most update to .env file content for reading.
                 */
                $dotenv = new Dotenv(base_path());
                $dotenv->load();

                $search = $key . '=' . getenv($key);
                $replace = $key . '=' . $value;

                $subject = str_replace($search, $replace, $subject);
            }

            file_put_contents($path, $subject);
        }
    }
public static function updateEnvSetting(array $settings, $path = null)
    {
        if (empty($path)) {
            $path = base_path('.env');
        }

        if (file_exists($path)) {
            $subject = file_get_contents($path);

            foreach ($settings as $key => $value) {
                // Uncomment if any of keys are commented out by default.
                $subject = str_replace(['#' . $key, '##$key'], $key, $subject);
            }

            // Update uncommented keys.
            file_put_contents($path, $subject);

            foreach ($settings as $key => $value) {
                /**
                 * Using a new instance of dotenv to get the
                 * most update to .env file content for reading.
                 */
                $dotenv = new Dotenv(base_path());
                $dotenv->load();

                $search = $key . '=' . getenv($key);
                $replace = $key . '=' . $value;

                $subject = str_replace($search, $replace, $subject);
            }

            file_put_contents($path, $subject);
        }
    }
public static function updateEnvSetting ( array $ settings , $ path = null ) { if ( empty ( $ path ) ) { $ path = base_path ( '.env' ) ; } if ( file_exists ( $ path ) ) { $ subject = file_get_contents ( $ path ) ; foreach ( $ settings as $ key => $ value ) { // Uncomment if any of keys are commented out by default. $ subject = str_replace ( [ '#' . $ key , '##$key' ] , $ key , $ subject ) ; } // Update uncommented keys. file_put_contents ( $ path , $ subject ) ; foreach ( $ settings as $ key => $ value ) { /**
                 * Using a new instance of dotenv to get the
                 * most update to .env file content for reading.
                 */ $ dotenv = new Dotenv ( base_path ( ) ) ; $ dotenv -> load ( ) ; $ search = $ key . '=' . getenv ( $ key ) ; $ replace = $ key . '=' . $ value ; $ subject = str_replace ( $ search , $ replace , $ subject ) ; } file_put_contents ( $ path , $ subject ) ; } }
Updates .env file setting.

@param array $settings
@param null  $path
Updates . env file setting .