{"id":18624550,"url":"https://github.com/zvps/laravel-4-env-polyfill","last_synced_at":"2026-06-30T11:31:26.709Z","repository":{"id":57092331,"uuid":"113032694","full_name":"zVPS/laravel-4-env-polyfill","owner":"zVPS","description":"Enables the env() function for providing default environment values and retrieving a variable from $_ENV.","archived":false,"fork":false,"pushed_at":"2018-02-13T09:01:36.000Z","size":18,"stargazers_count":0,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-17T07:07:00.966Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zVPS.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-12-04T11:10:46.000Z","updated_at":"2017-12-04T19:37:47.000Z","dependencies_parsed_at":"2022-08-22T21:40:18.133Z","dependency_job_id":null,"html_url":"https://github.com/zVPS/laravel-4-env-polyfill","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zVPS%2Flaravel-4-env-polyfill","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zVPS%2Flaravel-4-env-polyfill/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zVPS%2Flaravel-4-env-polyfill/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zVPS%2Flaravel-4-env-polyfill/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zVPS","download_url":"https://codeload.github.com/zVPS/laravel-4-env-polyfill/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zVPS%2Flaravel-4-env-polyfill/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259048344,"owners_count":22797713,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-07T04:29:28.694Z","updated_at":"2026-06-30T11:31:26.633Z","avatar_url":"https://github.com/zVPS.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Laravel 4 Env Polyfill\n\nLaravel 5 has a nice function `env()` which can assign a default variable if empty/null/blank. \n\nLaravel 4 applications are generally missing this functionality and if not running on \u003e= `PHP 7.0` can't use the ?? notation \nto keep `(isset($_ENV(thing))) ? $_ENV(thing) : default` short and sweet e.g `$_ENV(thing) ?? default`.\n\n## Installation\n\n    composer require zvps/laravel-4-env-polyfill\n\n## Setup\n\nMake sure to start using the detectEnvironment functionality inside `boostrap/start.php` so `.env.local.php` for example are available and selected correctly.\n\n\n    $env = $app-\u003edetectEnvironment(array(\n      'local' =\u003e array('your-machine-name'),\n    ));\n\n\nNext setup .env files and a .env.example.php so required defaults are documented.\n\n    .env.local.php\n\n\n\n    \u003c?php\n    return array(\n      'DATABASE_NAME' =\u003e 'my_database',\n      'DATABASE_USER' =\u003e 'username',\n      'DATABASE_PASSWORD' =\u003e 'totally_secure_password'\n    );\n\nNext update all files in `app/config/*.php` with the env() polyfill:\n\n\nWithout polyfill:\n\n    'host'      =\u003e if(isset($_ENV['DATABASEHOST']) ? $_ENV['DATABASE_HOST'] : 'localhost',\n    'database'  =\u003e if(isset($_ENV['DATABASE_NAME']) ? $_ENV['DATABASE_NAME'] : 'default_db',\n    'username'  =\u003e if(isset($_ENV['DATABASE_USERNAME']) ? $_ENV['DATABASE_USERNAME'] : 'default_user',\n    'password'  =\u003e if(isset($_ENV['DATABASE_PASSWORD']) ? $_ENV['DATABASE_PASSWORD'] : 'default_pass',\n\nWith polyfill:\n\n    'host'      =\u003e env('DATABASE_HOST', 'localhost')\n    'database'  =\u003e env('DATABASE_NAME', 'default_db'),\n    'username'  =\u003e env('DATABASE_USER', 'default_user'),\n    'password'  =\u003e env('DATABASE_PASSWORD', 'default_pass')\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzvps%2Flaravel-4-env-polyfill","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzvps%2Flaravel-4-env-polyfill","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzvps%2Flaravel-4-env-polyfill/lists"}