Last active
May 2, 2023 14:53
-
-
Save robertopc/b0548545611459db08ee6bbe20088bfe to your computer and use it in GitHub Desktop.
Read .env files in PHP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$consts = parse_ini_file('.env'); | |
foreach($consts as $k => $i){ | |
if(!defined($k)) | |
define($k, $i); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This code can read a .env like the sample and create the constants for use in PHP