sixlive / dotenv-editor Goto Github PK
View Code? Open in Web Editor NEWA PHP Package for editing dotenv files
License: MIT License
A PHP Package for editing dotenv files
License: MIT License
When exporting a .env
file, values are never wrapped in quotes. When a value contains certain characters, like =
, $
, or \n
(new line), this causes the resultant contents to be invalid.
E.g.
<?php
use sixlive\DotenvEditor\DotenvEditor;
include "vendor/autoload.php";
$editor = new DotenvEditor;
$editor->load(__DIR__.'/.env');
$editor->heading('Examples');
$editor->set('A', 't9maWr2GA6=');
$editor->set('B', 'this-should-be-$ingle-quoted');
$editor->set('C', 'multi
line
should be
quoted');
$editor->save();
Results in
# Examples
A=t9maWr2GA6=
B=this-should-be-$ingle-quoted
C=multi
line
should be
quoted
This is not a valid dotenv file and, for example, Laravel will not be able to load it.
dotenv-editor/src/DotenvEditor.php
Line 155 in edf0a75
There needs to be some different preparation of values, that need quoting, prior to writing them to the .env
file.
For example:
=
, #
, or a $
as part of variable/command substitution (e.g. "$(bleh)"
or "${FOO}"
) then wrap in double quotes$
not used for variable/command substitution, then wrap in single quotes\n
) either wrap in double quotes and\or convert the new line characters to a \n
literal stringAPP_KEY=base64...
gets reset to just APP_KEY
Keep the value of APP_KEY
No
No
Operating System: OSX Mojave
Package Version: v1.1.0
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.