Download the PHP package solophp/dotenv without Composer
On this page you can find all versions of the php package solophp/dotenv. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Please rate this library. Is it a good library?
Informations about the package dotenv
Solo Dotenv
Simple, zero-dependency .env loader for PHP. Loads environment variables from files into $_ENV (optionally also $_SERVER). No global putenv calls, no magic variable expansion.
Features
- Small and focused: just parsing and loading
- Zero dependencies
- Deterministic overrides: later files in the same call override earlier ones
- Typed accessors:
string,int,bool, andrequired
Installation
Quick start
API
Dotenv::load(string $baseDir, array $filenames = ['.env', '.env.local'], bool $overwrite = false, bool $populateServer = false): void- Loads files in order. Existing environment variables set before the call are preserved by default. Variables set by earlier files in the same call can be overridden by later files.
- Set
$overwrite = trueto overwrite any existing$_ENVvalues. - Set
$populateServer = trueto mirror values into$_SERVER.
Dotenv::get(string $key, mixed $default = null): mixedDotenv::string(string $key, string $default = ''): stringDotenv::int(string $key, int $default = 0): intDotenv::bool(string $key, bool $default = false): boolDotenv::required(string $key): string— throwsInvalidArgumentExceptionif missing/empty.
Parser
The parser is implemented in Solo\Dotenv\EnvParser and supports:
- Lines like
KEY=VALUE - Optional leading
export - Single and double quotes
- Inline comments for unquoted values (
FOO=bar # comment) - No variable expansion (by design)
Testing
License
MIT
All versions of dotenv with dependencies
PHP Build Version
Package Version
Requires
php Version
^8.0
The package solophp/dotenv contains the following files
Loading the files please wait ...