The humble .env file is a useful and low-tech way of storing persistent environment variables. Drop the file on your server and let your PHP scripts consume it with glee. But consume it how? There are lots of excellent parsing libraries for PHP. But isn’t there a simpler way? Yes! You can use PHP’s parse_ini_file() function and it works. But… .env and .ini have subtly different behaviour which …

  • luciole (they/them)@beehaw.org
    link
    fedilink
    arrow-up
    3
    ·
    2 days ago

    TLDR:

    You should probably use a proper parser rather than hoping your .env looks enough like an .ini to pass muster.

    You can probably use a butter knife instead of a flat screwdriver but just do your job properly.