peachpear / phpdotenv
phpdotenv is a environment config classs
Installs: 5
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/peachpear/phpdotenv
Requires
- php: >=5.1.0
This package is not auto-updated.
Last update: 2025-10-21 20:58:25 UTC
README
phpdotenv is a php environment config classs
Usage
The .env file, eg:
name = app
[app]
debug = "true"
trace = "false"
[database]
hostname = 127.0.0.1
database = test
username = abc
password = 123456
hostport = 3306
The file index.php, eg:
Dotenv\Dotenv::load(__DIR__ . "/.env");
The config file, eg:
define("APP_NAME", Dotenv\Dotenv::get("name"));
define("APP_DEBUG", Dotenv\Dotenv::get("app.debug"));
define("APP_TRACE", Dotenv\Dotenv::get("app.trace"));
$database_config = [
    "hostname" => Dotenv\Dotenv::get("database.hostname"),
    "database" => Dotenv\Dotenv::get("database.database"),
    "username" => Dotenv\Dotenv::get("database.username"),
    "password" => Dotenv\Dotenv::get("database.password"),
    "hostport" => Dotenv\Dotenv::get("database.hostport"),
];