PHPackages                             lexxyit/env-parser - 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. lexxyit/env-parser

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

lexxyit/env-parser
==================

Parsing the .env file to add new variables to the global environment.

1.0.1(3y ago)049MITPHPPHP &gt;=7.0

Since Apr 14Pushed 3y ago1 watchersCompare

[ Source](https://github.com/LeXxyIT/EnvParser)[ Packagist](https://packagist.org/packages/lexxyit/env-parser)[ Docs](https://github.com/LeXxyIT)[ RSS](/packages/lexxyit-env-parser/feed)WikiDiscussions master Synced 1w ago

READMEChangelogDependenciesVersions (2)Used By (0)

`.env` file is used very often in projects. Especially when it comes to some kind of powerful framework. It would be very convenient to add variables from the `.env` file, for example, directly to the `$_ENV` array and use them from there. `EnvParser` is a very simple and fast class for adding some settings to global variables. `EnvParser` has no external dependencies, which guarantees that it is simplicity and fast. It's installation is very simple.

> **Note:** The minimum required `PHP` version is `7.4`

1. Install package:

```
composer require lexxyit/env-parser
```

2. Create environment file `.env` at the root directory of your project:

```
DB_HOST=127.0.0.1
DB_PORT=3306
DB_USER=user
DB_PASSWORD=password

```

3. Now, let's try to use package. We need to call it's public `load()` method. This method needs only one `string ` parameter with path to your `.env` file. In my case I include it before the code with connecting to database. It can be done in several ways.

- Create extra variable to instantiate the `EnvParser` class and then use the `load()` method:

    ```
    $envParser = new LeXxyIT\EnvParser\EnvParser();
    $envParser->load(__DIR__ . '/.env');

    // ... database connection ...
    ```
- Create an instance of the `EnvParser` class with a short notation to use quickly the `load()` method:

    ```
    (new LeXxyIT\EnvParser\EnvParser())->load(__DIR__ . '/.env');

    // ... database connection ...
    ```
- Use `load()` as a static method:

    ```
    LeXxyIT\EnvParser\EnvParser::load(__DIR__ . '/../_Packagist/EnvParser/.env');

    // ... database connection ...
    ```

As a result, the variables will be added to the global environment and you will be able to use it in your code. Now, you can check it:

```
print_r($_ENV);
```

Result:

```
Array
(
    [DB_HOST] => 127.0.0.1
    [DB_PORT] => 3306
    [DB_USER] => user
    [DB_PASSWORD] => password
)

```

Enjoy it!

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity39

Early-stage or recently created project

 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

1130d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/2e415df3ae6b8ba8824eb213ec135e556db94804bb99677e100e64b82963e8f7?d=identicon)[LeXxyIT](/maintainers/LeXxyIT)

---

Top Contributors

[![LeXxyIT](https://avatars.githubusercontent.com/u/57368997?v=4)](https://github.com/LeXxyIT "LeXxyIT (12 commits)")

---

Tags

phpconfigurationconfigenvironmentenvdotenvvariablesphpdotenv

### Embed Badge

![Health badge](/badges/lexxyit-env-parser/health.svg)

```
[![Health](https://phpackages.com/badges/lexxyit-env-parser/health.svg)](https://phpackages.com/packages/lexxyit-env-parser)
```

###  Alternatives

[cekurte/environment

A library to get the values from environment variables and process to php data types

5884.0k7](/packages/cekurte-environment)

PHPackages © 2026

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