{"id":22169698,"url":"https://github.com/onesoft-sudo/envoy","last_synced_at":"2025-03-24T17:23:33.240Z","repository":{"id":57033466,"uuid":"435527144","full_name":"onesoft-sudo/envoy","owner":"onesoft-sudo","description":"A simple environment configuration loader.","archived":false,"fork":false,"pushed_at":"2022-08-16T14:19:58.000Z","size":74,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-29T22:18:08.647Z","etag":null,"topics":["env","environment-variables","php"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/onesoft-sudo.png","metadata":{"files":{"readme":"README.md","changelog":"ChangeLog.md","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":"2021-12-06T14:25:57.000Z","updated_at":"2022-05-06T07:55:50.000Z","dependencies_parsed_at":"2022-08-24T11:52:43.566Z","dependency_job_id":null,"html_url":"https://github.com/onesoft-sudo/envoy","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/onesoft-sudo%2Fenvoy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/onesoft-sudo%2Fenvoy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/onesoft-sudo%2Fenvoy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/onesoft-sudo%2Fenvoy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/onesoft-sudo","download_url":"https://codeload.github.com/onesoft-sudo/envoy/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245316047,"owners_count":20595370,"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":["env","environment-variables","php"],"created_at":"2024-12-02T06:34:29.640Z","updated_at":"2025-03-24T17:23:33.213Z","avatar_url":"https://github.com/onesoft-sudo.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Envoy\n[![PHP Composer](https://github.com/onesoft-sudo/envoy/actions/workflows/php.yml/badge.svg)](https://github.com/onesoft-sudo/envoy/actions/workflows/php.yml)\n[![Packagist Version](https://img.shields.io/packagist/v/osn/envoy?label=Packagist)](https://packagist.org/packages/osn/envoy)\n![](https://img.shields.io/packagist/dt/osn/envoy?label=Downloads)\n\nA simple environment configuration loader.\n \n## Installation\nYou can install envoy using composer:\n \n```\n$ composer require osn/envoy\n```\n\n## Usage\nOnce you've installed envoy, you can include the composer-generated autoloader into your project and start writing code:\n\n```php\n\u003c?php\n  require __DIR__ . \"/vendor/autoload.php\";\n  \n  // ...\n```\n\nOkay, now you're ready to go!\nLet's see how to invoke envoy. \n\nYou need to create an `OSN\\Envoy\\Envoy` object first. The `Envoy` constructor accepts parameter 1 as the env file path, and the second argument is the configuration array.\nBoth of these are optional but note that argument 1 defaults to `./.env`.\n\nThen you need to call the `load()` method on the instance to load all the configuration from the env file to super global `$_ENV`.\n\nIf there was an error while parsing the file, Envoy will throw `OSN\\Envoy\\EntityParseErrorException`.\n\n```php\n\u003c?php\n  require __DIR__ . \"/vendor/autoload.php\";\n  \n  use OSN\\Envoy\\Envoy;\n  \n  $envoy = new Envoy();\n  \n  try {\n    $envoy-\u003eload();\n    print_r($_ENV);\n  }\n  catch(\\OSN\\Envoy\\EntityParseErrorException $e){\n    echo \"Error while parsing the file: \" . $e-\u003egetMessage();\n  }\n```\n\nIf the `.env` file is this:\n\n```\nDSN=mysql:host=localhost;port=3306;dbname=mydatabase\nDB_USER=root\nDB_PASSWORD= \n```\n\nThen the above code should print:\n\n```\nArray (\n  [DSN] =\u003e mysql:host=localhost;port=3306;dbname=mydatabase\n  [DB_USER] =\u003e root\n  [DB_PASSWORD] =\u003e\n)\n```\n\n## Configuration\nWhen you create the `Envoy` object, you can pass the config array as second parameter to the constructor. The array follows the follwing structure:\n\n```php\n[\n    \\OSN\\Envoy\\Envoy::CONFIG_OPTION_HERE =\u003e \"value\",\n    \\OSN\\Envoy\\Envoy::CONFIG_OPTION_2 =\u003e true,\n]\n```\n\n### Available Configuration Options\n\nOption                       |Values|Description\n-----------------------------|------|---------------------------------------------------------------------------------------------\n`CONFIG_ASSIGN_ENV_TO_SERVER`|`bool`|Specify that envoy should also push the environment variables to the super global `$_SERVER`.\n\n## Support\nPlease contact us at [envoy@onesoftnet.eu.org](mailto:envoy@onesoftnet.eu.org).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fonesoft-sudo%2Fenvoy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fonesoft-sudo%2Fenvoy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fonesoft-sudo%2Fenvoy/lists"}