Created
December 16, 2022 15:01
-
-
Save magnum/4d7ae490ec91b6b5bdacd9b135e190c3 to your computer and use it in GitHub Desktop.
dotenv support in php, eg. wordpress
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 | |
try { | |
require_once 'vendor/autoload.php'; | |
$dotenv = Dotenv\Dotenv::createUnsafeImmutable('./'); | |
$dotenv->load(); | |
} catch (Exception $e) { | |
echo(implode("<br>", array( | |
("Caught exception: ".$e->getMessage()."<br>"), | |
"please be sure to install .env support package with 'composer require vlucas/phpdotenv'", | |
"and that a .env is present" | |
))); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment