Repository navigation
This release contains breaking changes. Read the upgrade guide before updating to solophp/dotenv:^2.0. Documentation: https://solophp.github.io/Dotenv/
Added
Dotenv::read()returns the merged file values as an array without touching the environment.ParseExceptionreports the source and one-based line number of malformed syntax.- Double-quoted values decode
\n,\r,\t,\"and\\. - CR line endings and a leading UTF-8 BOM are supported.
Changed
- PHP 8.3 or newer is required.
- Malformed lines, invalid names, unterminated quotes and text after a closing quote raise
ParseExceptioninstead of being skipped or stored as written. #starts an inline comment only after a space or tab, soTOKEN=abc#123keeps the hash.- A missing or inaccessible base directory, an unreadable file or a broken symlink raises
RuntimeException. Absent files are still skipped. - An empty filename or one containing a null byte raises
InvalidArgumentException. load()applies no values unless every file is read and parsed successfully.load()keeps values already present in$_SERVERunlessoverwriteis set.HTTP_*entries in$_SERVERare ignored.int()accepts only decimal integers within the platform range. Fractions, exponents and overflowing values return the default.string()returns the default for non-scalar values.required()throws for non-scalar values and for values that convert to an empty string, with a new message.
Security
get()and the typed accessors no longer readHTTP_*keys from$_SERVER, which web servers fill from client request headers.populateServerno longer writes those keys to$_SERVER.- Parser arguments are marked
#[\SensitiveParameter], so file contents and values stay out of exception stack traces.
Full changelog: CHANGELOG.md · v1.0.0...v2.0.0