PHPackages                             knorkfork/load-environment - 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. knorkfork/load-environment

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

knorkfork/load-environment
==========================

Load environment variables from .env file

v1.0.0(1y ago)0171MITPHPPHP &gt;=8.2

Since Feb 21Pushed 9mo ago1 watchersCompare

[ Source](https://github.com/knork-fork/load-environment)[ Packagist](https://packagist.org/packages/knorkfork/load-environment)[ RSS](/packages/knorkfork-load-environment/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (3)Versions (2)Used By (0)

### Load environment

[](#load-environment)

Load environment variables from `.env` (and `.env.local`) into PHP.

#### Installation

[](#installation)

```
composer require knorkfork/load-environment
```

#### Usage

[](#usage)

Assuming .env file and .php file are in the same folder, you can load environment variables like this:

```
use KnorkFork\LoadEnvironment\Environment;

Environment::load(__DIR__ . '/.env');

echo Environment::getStringEnv('APP_ENV');
```

By default it will also try to load `.env.local` file if it exists.

All variables set in `.env.local` will overwrite variables from `.env`.

---

If you want to load from custom env file, pass it via second argument.

```
use KnorkFork\LoadEnvironment\Environment;

Environment::load(__DIR__ . '/.env', ['custom']);

// APP_ENV from .env will be overwritten by APP_ENV from .env.custom
echo Environment::getStringEnv('APP_ENV');
```

---

Environment variables can also be accessed without `Environment` class.

```
use KnorkFork\LoadEnvironment\Environment;

Environment::load(__DIR__ . '/.env');

echo getenv('APP_ENV');
```

###  Health Score

32

—

LowBetter than 69% of packages

Maintenance49

Moderate activity, may be stable

Popularity11

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity50

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

Unknown

Total

1

Last Release

497d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/37639964?v=4)[Luka](/maintainers/knork-fork)[@knork-fork](https://github.com/knork-fork)

---

Top Contributors

[![knork-fork](https://avatars.githubusercontent.com/u/37639964?v=4)](https://github.com/knork-fork "knork-fork (6 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/knorkfork-load-environment/health.svg)

```
[![Health](https://phpackages.com/badges/knorkfork-load-environment/health.svg)](https://phpackages.com/packages/knorkfork-load-environment)
```

###  Alternatives

[beelab/recaptcha2-bundle

Provide Google Recaptcha2 form type

55480.4k1](/packages/beelab-recaptcha2-bundle)[obsh/sse-client

Server Sent Event client implementation

236.0k](/packages/obsh-sse-client)

PHPackages © 2026

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