Download the PHP package 0.0.0/laravel-env-shim without Composer
On this page you can find all versions of the php package 0.0.0/laravel-env-shim. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package laravel-env-shim
Laravel 5.7 env() Polyfill
Benefits
- Works with any package, even non-Laravel ones (it was my secondary reason)
- You no longer have to fear Laravel just going one day "Oops! We're not going to read from the environment anymore! Too bad!" on a non-major release.
Backstory
With the introduction of Laravel 5.8, they broke the essential env()
function
by changing it from reading from/writing to environment variables to only using
the global $_SERVER
array, which is totally useless in console-based apps.
See
- https://github.com/laravel/framework/pull/27462
- https://github.com/laravel/framework/issues/27828
- https://github.com/laravel/framework/issues/27949
Therefore, I took it upon myself to create this polyfill to ensure that the pre-5.8 behaviors remain intact.
Additionally, this is a great little utility function to use outside of Laravel-specic
projects that also want to use the env()
function.
It is specially configured with a 0.0.1
composer vendor and a AAutoloadFirst
namespace, so that composer will always load it before it gets to Laravel.
See https://github.com/composer/composer/issues/6768
The source code is lifted directly from the last version of Laravel 5.7.
As you can imagine, most of the copyright in this project belongs to Taylor Otwell, 2018.
It also includes 100% unit test code .
Installation
Via Composer
Usage
and
Use cases
PHPExperts\Laravel57EnvPolyfill\Tests\Env
✔ Env
✔ Env with quotes
✔ Env true
✔ Env false
✔ Env empty
✔ Env null
✔ Value
✔ Env will use default value if needed
✔ Will load vlucas/phpdot if a .env is present.
✔ Will not load vlucas/phpdotenv if a .env is not present.
Testing
Contributors
Theodore R. Smith [email protected]
GPG Fingerprint: 4BF8 2613 1C34 87AC D28F 2AD8 EB24 A91D D612 5690
CEO: PHP Experts, Inc.
License
MIT license. Please see the license file for more information.