PHPackages                             tomrf/dotenv - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. tomrf/dotenv

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

tomrf/dotenv
============

simple dotenv file loader using the built-in parse\_ini\_file()

0.0.5(2y ago)2411MITPHPPHP ^8.0

Since Jun 3Pushed 2y ago1 watchersCompare

[ Source](https://github.com/tomrf/dotenv)[ Packagist](https://packagist.org/packages/tomrf/dotenv)[ Docs](http://github.com/tomrf/dotenv)[ RSS](/packages/tomrf-dotenv/feed)WikiDiscussions master Synced 1w ago

READMEChangelogDependencies (6)Versions (6)Used By (1)

dotenv - simple dotenv file loader using the built-in parse\_ini\_file()
========================================================================

[](#dotenv---simple-dotenv-file-loader-using-the-built-in-parse_ini_file)

[![PHP Version Require](https://camo.githubusercontent.com/741813a9d9f14f3b9bfc81d19df7b636b283bf31365008dc7dc5e23492338180/687474703a2f2f706f7365722e707567782e6f72672f746f6d72662f646f74656e762f726571756972652f7068703f7374796c653d666c61742d737175617265)](https://packagist.org/packages/tomrf/dotenv) [![Latest Stable Version](https://camo.githubusercontent.com/cb6935dbac6b7c9a5756a468c3c2bc16ac1ce406ae95848db0b11e387c81790f/687474703a2f2f706f7365722e707567782e6f72672f746f6d72662f646f74656e762f763f7374796c653d666c61742d737175617265)](https://packagist.org/packages/tomrf/dotenv) [![License](https://camo.githubusercontent.com/62da08483d73a4279dd7b34651a528aab297a2a7da99f06ac0e601259a3bdf02/687474703a2f2f706f7365722e707567782e6f72672f746f6d72662f646f74656e762f6c6963656e73653f7374796c653d666c61742d737175617265)](https://packagist.org/packages/tomrf/dotenv)

Load environment variables from dotenv file using the PHP built-in parse\_ini\_file() function with scanner mode `INI_SCANNER_TYPED` (See [PHP manual](https://www.php.net/manual/en/function.parse-ini-file.php))

It is a simple, reliable and super fast way to load dotenv files without any bells nor whistles.

📔 [Go to documentation](#documentation)

Installation
------------

[](#installation)

Installation via composer:

```
composer require tomrf/dotenv
```

Usage
-----

[](#usage)

```
$dotEnvLoader = new \Tomrf\DotEnv\DotEnvLoader();

// loadImmutable() will not overwrite existing environment variables
$dotEnvLoader->loadImmutable(__DIR__ . '/.env');

// load() will overwrite existing environment variables
$dotEnvLoader->load('/path/to/dotenv/file');
```

Testing
-------

[](#testing)

```
composer test
```

License
-------

[](#license)

This project is released under the MIT License (MIT). See [LICENSE](LICENSE) for more information.

Documentation
-------------

[](#documentation)

- [Tomrf\\DotEnv\\DotEnvLoader](#-tomrfdotenvdotenvloaderclass)
    - [load](#load)
    - [loadImmutable](#loadimmutable)

---

### 📂 Tomrf\\DotEnv\\DotEnvLoader::class

[](#-tomrfdotenvdotenvloaderclass)

Simple dotenv loader using parse\_ini\_file().

#### load()

[](#load)

Loads dotenv file into local environment, overwriting any environment variable already set.

```
public function load(
    string $filename
): void

@throws   \Tomrf\DotEnv\DotEnvLoaderException if parsing fails or if the file is not found
```

#### loadImmutable()

[](#loadimmutable)

Loads dotenv file into local environment while preserving any existing environment variable.

```
public function loadImmutable(
    string $filename
): void

@throws   \Tomrf\DotEnv\DotEnvLoaderException if parsing fails or if the file is not found
```

---

*Generated 2023-04-21T13:16:14+00:00 using 📚[tomrf/readme-gen](https://packagist.org/packages/tomrf/readme-gen)*

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~106 days

Total

5

Last Release

1020d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/c2113e52873316a5ad6f705f08f4218b2ee8c4348b0c693bb87bd9359908d23f?d=identicon)[tom@upnode.no](/maintainers/tom@upnode.no)

---

Top Contributors

[![tomrf](https://avatars.githubusercontent.com/u/1669009?v=4)](https://github.com/tomrf "tomrf (10 commits)")

---

Tags

dotenvdotenv-parserenvironment-variablesini-parserini-readerphpphp-dotenvenvironmentenvdotenvenvironment variables

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/tomrf-dotenv/health.svg)

```
[![Health](https://phpackages.com/badges/tomrf-dotenv/health.svg)](https://phpackages.com/packages/tomrf-dotenv)
```

###  Alternatives

[vlucas/phpdotenv

Loads environment variables from `.env` to `getenv()`, `$\_ENV` and `$\_SERVER` automagically.

13.5k602.4M5.4k](/packages/vlucas-phpdotenv)[symfony/dotenv

Registers environment variables from a .env file

3.8k226.7M2.3k](/packages/symfony-dotenv)[diarmuidie/envpopulate

Tool to interactively populate a `.env` file based on an `.env.example` file whenever Composer installs or updates.

1892.0k](/packages/diarmuidie-envpopulate)[zepgram/magento-dotenv

Simple autoloader to integrate the Symfony Dotenv component into Magento2

1371.3k](/packages/zepgram-magento-dotenv)[nystudio107/dotenvy

Speed up your production sites by ditching .env for key/value variable pairs as Apache, Nginx, and shell equivalents.

326.9k](/packages/nystudio107-dotenvy)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
