Secrets · Guides
Import a .env
Paste the .env you have into an environment. You see what each line would do first, and nothing changes until you import.
Paste and check
On an environment's list, choose Import a .env, paste the file and choose Check. The next page shows what importing would do, line by line. Importing takes Triage or Admin in the environment. A pasted .env is at most 256 KB.
The pasted text goes from page to page with the form and is never stored on its own. If something is refused, paste it again.
What is read
A .env is read the way Laravel reads one, so a file that works there imports as it is:
# Comments and blank lines are skipped
APP_NAME="My Shop"
export APP_URL=https://shop.example.com
DB_PASSWORD='p#ss word'
MAIL_FROM=shop@example.com # a comment after a space
PRIVATE_KEY="-----BEGIN PRIVATE KEY-----
MIIEvQ…
-----END PRIVATE KEY-----"- Blank lines and lines starting with
#are skipped. exportin front of a name is dropped.- A bare value runs to the end of the line, or to a
#, which starts a comment. It's trimmed. - A value in
'single quotes'is kept exactly as written,#and all. - A value in
"double quotes"understands\n,\r,\t,\f,\v,\",\\and\$. Either kind of quote may span lines, as the private key above does. ${OTHER}is kept as written: one variable doesn't refer to another.
A # in a bare value
PASS=abc#123 reads as abc: the rest is a comment. The check marks such a line with a caution. Put the value in quotes to keep all of it.What each line does
| The check says | What it means |
|---|---|
| Adds | The name isn't in the environment yet. It arrives Secret, or Visible if you tick it. |
| Changes | The name is there with another value. It keeps being Secret or Visible, as it is. |
| Same already | The name is there with this value. Nothing happens to it. |
| Skipped | The line can't be imported. The reason is beside it. |
For a Visible variable the check shows the old and new value; for a Secret one, never. Each name it adds has a Visible tick, set for you when the name looks like nothing to hide: see What is suggested.
Why a line is skipped
A skipped line is named by its number, never shown, since it may hold a secret. The reasons:
| Reason | What it means |
|---|---|
| No = on this line. | A line that is neither a comment nor NAME=value. |
| Not a NAME=value line. | Something before the = that isn't a name. |
| Not an UPPER_SNAKE name. | A name such as app_name or App-Name. Rename it in the text: a capital letter first, then capitals, digits and _. |
| Set again on line 12. | The name is set twice. The later line counts, as in every .env reader. |
| Its " quote is never closed, so nothing after it is read. | A quote opened and never closed. The lines after it are not read either. |
| Something other than a comment follows the closing quote. | Text after a quoted value, such as KEY="a"b. |
| The value is over 32 KB. | One value is too big. |
| The value holds a NUL byte. | A value with a zero byte, which no environment variable can hold. |
Change the text in the box and choose Check again.
Import
The button at the foot says what it does, such as Import 12 into staging. Then:
- Everything that adds or changes arrives as one change in the history, Imported, which a single roll back undoes.
- Names already in the environment that the file leaves out stay as they are. An import never removes a variable.
- If the text was changed after the check, nothing is imported: the page shows what it would do now, to import once it looks right.
- If the new names don't fit in the package's variables per environment, the whole import is refused and nothing changes. See Limits.