Skip to content

Add support for BOM-signed env files #500

@hosni

Description

@hosni

Hi!
I was working on a Laravel project that has a .env file.
But I faced an error that says:
The environment file is invalid!
Failed to parse dotenv file due to an invalid name. Failed at [APP_NAME].

After some time for debugging, I realized the problem is come from encoding of the file!
The encoding of the .env file is UTF8 BOM

In this example files you will see two files named .env-UTF-8 and .env-UTF-8-with-BOM. They almost contains the same data, but .env-UTF-8-with-BOM starts with the UTF8 BOM, causing the parse error.

image

image

How did happen?

I'm using linux as OS, but well it seems that when you add a text file in Visual Studio in windows, it adds the UTF8 BOM by default. I generated the second file that has to BOM using the Windows Explorer contextual menu "New File".

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions