Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

update laravel .env variables dynamically

   /**
     * Update Laravel Env file Key's Value
     * @param string $key
     * @param string $value
     */
    public static function envUpdate($key, $value)
    {
        $path = base_path('.env');

        if (file_exists($path)) {

            file_put_contents($path, str_replace(
                $key . '=' . env($key), $key . '=' . $value, file_get_contents($path)
            ));
        }
    }
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #update #laravel #variables #dynamically
ADD COMMENT
Topic
Name
5+2 =