PHPackages                             geerthauwaerts/now-env - 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. geerthauwaerts/now-env

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

geerthauwaerts/now-env
======================

Load the `now.json` variables into your development environment.

1.0.0(7y ago)15[2 issues](https://github.com/GeertHauwaerts/now-env/issues)BSD-3-ClauseShellPHP &gt;=7.2CI failing

Since Dec 6Pushed 5y ago1 watchersCompare

[ Source](https://github.com/GeertHauwaerts/now-env)[ Packagist](https://packagist.org/packages/geerthauwaerts/now-env)[ RSS](/packages/geerthauwaerts-now-env/feed)WikiDiscussions master Synced today

READMEChangelog (1)Dependencies (1)Versions (2)Used By (0)

PHP NowEnv
----------

[](#php-nowenv)

Load the `now.json` variables into your development environment.

With the help of this package, you can easily use your Now environment variables for the use in development.

If you're already using a `now.json` file, the `env` sub property will be assigned to `$_ENV`, `$_SERVER`, and `getenv()` automatically.

This package does absolutely nothing when running in a Now instance.

[![Build Status](https://camo.githubusercontent.com/dbc8e88a2045c82dab3083128fd66ee6af1c11cc64272e67af2c9d9e6e20535a/68747470733a2f2f7472617669732d63692e6f72672f47656572744861757761657274732f6e6f772d656e762e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/GeertHauwaerts/now-env)

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

[](#installation)

Use composer to add the library:

```
composer require geerthauwaerts/now-env
```

Usage
-----

[](#usage)

Add the `env` property to your `now.json` file and load the variables in your application with:

```
use NowEnv\NowEnv;

$nowenv = new NowEnv(__DIR__);
$nowenv->load();
```

Optionally you can pass in a filename as the second parameter, if you would like to use something other than `now.json`.

```
use NowEnv\NowEnv;

$nowenv = new NowEnv(__DIR__, 'now-secrets.json');
$nowenv->load();
```

All of the defined variables are now accessible with the `getenv` method, and are available in the `$_ENV` and `$_SERVER` super-globals.

```
$example = getenv('EXAMPLE');
$example = $_ENV['EXAMPLE'];
$example = $_SERVER['EXAMPLE'];
```

### Immutability

[](#immutability)

By default, NowEnv will NOT overwrite existing environment variables that are already set in the environment.

If you want NowEnv to overwrite existing environment variables, use `overload()`instead of `load()`:

```
use NowEnv\NowEnv;

$nowenv = new NowEnv(__DIR__);
$nowenv->overload();
```

### Requiring variables to be set

[](#requiring-variables-to-be-set)

You can require specific environment variables to be defined by passing a single string:

```
$nowenv->required('EXAMPLE');
```

Or an array of strings:

```
$nowenv->required(['EXAMPLE1', 'EXAMPLE2', 'EXAMPLE3']);
```

If any environment variables vars are missing, NowEnv will throw a `RuntimeException`like this:

```
One or more environment variables failed assertions: EXAMPLE is missing

```

### Empty variables

[](#empty-variables)

Beyond simply requiring a variable to be set, you might also need to ensure the variable is not empty:

```
$nowenv->required('EXAMPLE')->notEmpty();
```

If the environment variable is empty, you'd get an Exception:

```
One or more environment variables failed assertions: EXAMPLE is empty

```

### Integer variables

[](#integer-variables)

You might also need to ensure that the variable is of an integer value. You may do the following:

```
$nowenv->required('EXAMPLE')->isInteger();
```

If the environment variable is not an integer, you'd get an Exception:

```
One or more environment variables failed assertions: EXAMPLE is not an integer

```

Boolean variables
-----------------

[](#boolean-variables)

You may need to ensure a variable is in the form of a boolean. You may do the following:

```
$nowenv->required('EXAMPLE')->isBoolean();
```

If the environment variable is not a boolean, you'd get an Exception:

```
One or more environment variables failed assertions: EXAMPLE is not a boolean

```

### Allowed Values

[](#allowed-values)

It is also possible to define a set of values that your environment variable should be. This is especially useful in situations where only a handful of options or drivers are actually supported by your code:

```
$nowenv->required('EXAMPLE')->allowedValues(['VALUE1', 'VALUE2']);
```

If the environment variable wasn't in this list of allowed values, you'd get a similar Exception:

```
One or more environment variables failed assertions: EXAMPLE is not an allowed value

```

Collaboration
-------------

[](#collaboration)

The GitHub repository is used to keep track of all the bugs and feature requests; I prefer to work exclusively via GitHib and Twitter.

If you have a patch to contribute:

- Fork this repository on GitHub.
- Create a feature branch for your set of patches.
- Commit your changes to Git and push them to GitHub.
- Submit a pull request.

Shout to [@GeertHauwaerts](https://twitter.com/GeertHauwaerts) on Twitter at any time :)

Donations
---------

[](#donations)

If you like this project and you want to support the development, please consider to [donate](https://commerce.coinbase.com/checkout/45c6916d-19ae-40c9-8ef7-7fb7ad30f8e2); all donations are greatly appreciated.

- **[Coinbase Commerce](https://commerce.coinbase.com/checkout/45c6916d-19ae-40c9-8ef7-7fb7ad30f8e2)**: *BTC, BCH, DAI, ETH, LTC, USDC*
- **BTC**: *bc1q654z85zv6sujsjqk750sf4j4eahcckdtq0cqrp*
- **ETH**: *0x4d38b4EB5b0726Dc6bd5770F69348e7472954b41*
- **LTC**: *MBEaP6e4zwro6oNP54yjfC29fVqZ881wdF*
- **DOGE**: *D8LypNzP6GayEBWUKCw3KVc7gwbGBaXynT*

###  Health Score

19

—

LowBetter than 10% of packages

Maintenance0

Infrequent updates — may be unmaintained

Popularity5

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

Unknown

Total

1

Last Release

2714d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/3ca4caa9958e820bac1b6b7f971c2fb69b2d188693dcdee56d76c12692f735a0?d=identicon)[GeertHauwaerts](/maintainers/GeertHauwaerts)

---

Top Contributors

[![GeertHauwaerts](https://avatars.githubusercontent.com/u/7902071?v=4)](https://github.com/GeertHauwaerts "GeertHauwaerts (5 commits)")

---

Tags

envenvironmentnownow-envenvironmentenvnow-env

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/geerthauwaerts-now-env/health.svg)

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

###  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)[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)[mirazmac/dotenvwriter

A PHP library to write values to .env (DotEnv) files

19129.3k7](/packages/mirazmac-dotenvwriter)

PHPackages © 2026

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