PHPackages                             juanchosl/envvars - 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. juanchosl/envvars

ActiveLibrary

juanchosl/envvars
=================

A small, lightweight utility to read ENV files and append his content to environment variables

1.0.7(7mo ago)168MITPHPPHP ^7.1 || ^8.0

Since Oct 19Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/JuanchoSL/EnvVars)[ Packagist](https://packagist.org/packages/juanchosl/envvars)[ Docs](https://github.com/JuanchoSL/EnvVars)[ RSS](/packages/juanchosl-envvars/feed)WikiDiscussions 1.0 Synced 1mo ago

READMEChangelog (7)Dependencies (3)Versions (9)Used By (0)

EnvVars
=======

[](#envvars)

Description
-----------

[](#description)

A small, lightweight utility to read ENV files and append his content to environment variables.

This is a test project in order to check how works the composer installation directly from GitHub

Install
-------

[](#install)

```
composer require juanchosl/envvars
```

How to use it
-------------

[](#how-to-use-it)

Load composer autoload and use the JuanchoSL\\EnvVars\\EnvVars class, with abstract *read* method you can pass it the absolute file path or the dir path where the .ENV file are placed, the content has been putted into $\_ENV superglobal or you can use getenv(ENV\_VAR\_NAME) instead

```
use Juanchosl\EnvVars\EnvVars;
```

### Initialize

[](#initialize)

```
EnvVars::init(realpath(dirname(__DIR__, 1)) . DIRECTORY_SEPARATOR . '.env');
```

Or

```
EnvVars::init(dirname(__DIR__, 1));
```

### Configure

[](#configure)

We have some options for configure the use of the library, actually:

- OPTION\_PROCESS\_SECTIONS (default **false**)

```
EnvVars::init(dirname(__DIR__, 1), [
    EnvVars::OPTION_PROCESS_SECTIONS => true
]);
```

### Add more files

[](#add-more-files)

Now, you can parse more files with new env vars in order to add to scope

```
$envvar = EnvVars::init(dirname(__DIR__, 1).DIRECTORY_SEPARATOR.'.env-database');
$envvar->parseFile(dirname(__DIR__, 1).DIRECTORY_SEPARATOR.'.env-tokens')
```

### Call vars

[](#call-vars)

```
$env_var = getenv('ENV_VAR_NAME');
```

Or

```
$env_var = $_ENV['ENV_VAR_NAME'];
```

### Type of vars into .env file

[](#type-of-vars-into-env-file)

You can use as values for your variables:

- fixed values
- variable from other env settings
- strings and functions of php than can be evaluated

#### Literals

[](#literals)

```
VAR_KEY=var_value
```

#### Variables

[](#variables)

Yo can use other env var name as content for set a nev environment variable. The order is not strict for reuse static values into env vars, the system parse and set first the literal variables, then the dynamic content, the var as value is then available. Pay attention to put the variable in the correct format, start with a dollar and put the name of the key to search into brackets

```
ORIGINAL_KEY=var_value
CLONED_KEY=${ORIGINAL_KEY}
```

#### Evaluations

[](#evaluations)

The system can parse and evaluate native functions in order to solve complex values. Pay attention to put the strign to evaluate into doble quotes and finish with a semicolon

```
EVALUATED_KEY="dirname($_SERVER['DOCUMENT_ROOT']);"
```

OR

```
EVALUATED_KEY="$_SERVER['HTTP_HOST'];"
```

###  Health Score

39

—

LowBetter than 86% of packages

Maintenance72

Regular maintenance activity

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity56

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 ~154 days

Recently: every ~202 days

Total

8

Last Release

214d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/bd6d3dea7eb469817524c42a80683e95793ed4800a6794366503355af046a726?d=identicon)[Juanchosl](/maintainers/Juanchosl)

---

Top Contributors

[![JuanchoSL](https://avatars.githubusercontent.com/u/18701207?v=4)](https://github.com/JuanchoSL "JuanchoSL (44 commits)")

---

Tags

environmentenvenvvars

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/juanchosl-envvars/health.svg)

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

###  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.2k](/packages/symfony-dotenv)[jbzoo/utils

Collection of PHP functions, mini classes and snippets for everyday developer's routine life.

8321.5M36](/packages/jbzoo-utils)[imliam/laravel-env-set-command

Set a .env file variable from the command line

118352.4k10](/packages/imliam-laravel-env-set-command)[msztorc/laravel-env

Laravel env helper commands

7855.4k](/packages/msztorc-laravel-env)[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)
