PHPackages                             bubblegum-php/bubblegum-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. bubblegum-php/bubblegum-environment

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

bubblegum-php/bubblegum-environment
===================================

Environment manager module for BUBBLEGUM.

1.0.0(1y ago)0462MITPHPPHP ^8.0

Since Sep 26Pushed 1y agoCompare

[ Source](https://github.com/bubblegum-php/bubblegum-environment)[ Packagist](https://packagist.org/packages/bubblegum-php/bubblegum-environment)[ Docs](https://github.com/bubblegum-php/bubblegum-environment)[ RSS](/packages/bubblegum-php-bubblegum-environment/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (3)Used By (2)

bubblegum-environment
=====================

[](#bubblegum-environment)

.env configuration module for BUBBLEGUM

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

[](#installation)

Require this module with composer

`composer require bubblegum-php/bubblegum-environment`

Usage
-----

[](#usage)

Load environment
----------------

[](#load-environment)

### Getting environment variables

[](#getting-environment-variables)

You can simply use the `env` helper to get the environment variable.

```
env('VARIABLE_NAME', 'DefaultValue')
```

You can define a **default value** for a variable, which will be returned if the **environment variable** with the same name is not set. If neither a **default value** nor an **environment variable** is set, this method returns `null`.

### Get or Throw

[](#get-or-throw)

Throws an exception if an environment variable is not found.

```
use Bubblegum\Environment;

Environment::getOrThrow('VARIABLE_NAME'); // Throws an EnvironmentException if there is no variable named 'VARIABLE_NAME'
```

### Basic Load

[](#basic-load)

```
use Bubblegum\Environment;

Environment::loadFromFile('path/to/env/file');
```

### Load if not prevented

[](#load-if-not-prevented)

You can prevent the .env file loading if the environment already have the `PREVENT_ENV_FILE_LOADING` variable set to `true`.

```
name: bubblegum
services:
  php:
    build:
      context: ./docker/
      dockerfile: php.dockerfile
    env_file:
      - ./.env # we already have environment loading here
    environment:
      PREVENT_ENV_FILE_LOADING: true # so we don't need to load it
```

If loading is NOT prevented, this method will load the environment.

```
use Bubblegum\Environment;

Environment::loadIfNotPrevented('path/to/env/file');
```

### Put variables locally

[](#put-variables-locally)

You can put variables locally without saving them to a file.

```
use Bubblegum\Environment;
$value = 'Hello There!'
Environment::put('VARIABLE_NAME', $value);
env(VARIABLE_NAME) // returns 'Hello There!'
```

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance36

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity45

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

591d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/70edfbafddf09a40b40a2151c1f7c49b43f13469a2f007d8d2b8b5840b282134?d=identicon)[lankryf](/maintainers/lankryf)

---

Top Contributors

[![lankryf](https://avatars.githubusercontent.com/u/99345664?v=4)](https://github.com/lankryf "lankryf (8 commits)")

---

Tags

environmentbubblegumbubblegum-environment

### Embed Badge

![Health badge](/badges/bubblegum-php-bubblegum-environment/health.svg)

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

###  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)[foroco/php-browser-detection

Ultra fast PHP library to detect browser, OS, platform and device type by User-Agent parsing

1554.7M7](/packages/foroco-php-browser-detection)[wolfcast/browser-detection

The Wolfcast BrowserDetection PHP class facilitates the identification of the user's environment such as Web browser, version, platform family, platform version or if it's a mobile device or not.

1391.0M7](/packages/wolfcast-browser-detection)[imliam/laravel-env-set-command

Set a .env file variable from the command line

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

Provides an API for building environment tests

35503.8k13](/packages/silverstripe-environmentcheck)

PHPackages © 2026

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