PHPackages                             zvps/laravel-4-env-polyfill - 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. zvps/laravel-4-env-polyfill

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

zvps/laravel-4-env-polyfill
===========================

Enables the env() function for providing default environment values and retrieving a variable from $\_ENV.

v1.0.1(8y ago)02001[1 issues](https://github.com/zVPS/laravel-4-env-polyfill/issues)GPL-3.0-or-laterPHP

Since Dec 4Pushed 8y ago2 watchersCompare

[ Source](https://github.com/zVPS/laravel-4-env-polyfill)[ Packagist](https://packagist.org/packages/zvps/laravel-4-env-polyfill)[ RSS](/packages/zvps-laravel-4-env-polyfill/feed)WikiDiscussions master Synced today

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

Laravel 4 Env Polyfill
----------------------

[](#laravel-4-env-polyfill)

Laravel 5 has a nice function `env()` which can assign a default variable if empty/null/blank.

Laravel 4 applications are generally missing this functionality and if not running on &gt;= `PHP 7.0` can't use the ?? notation to keep `(isset($_ENV(thing))) ? $_ENV(thing) : default` short and sweet e.g `$_ENV(thing) ?? default`.

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

[](#installation)

```
composer require zvps/laravel-4-env-polyfill

```

Setup
-----

[](#setup)

Make sure to start using the detectEnvironment functionality inside `boostrap/start.php` so `.env.local.php` for example are available and selected correctly.

```
$env = $app->detectEnvironment(array(
  'local' => array('your-machine-name'),
));

```

Next setup .env files and a .env.example.php so required defaults are documented.

```
.env.local.php
