{"id":25456443,"url":"https://github.com/autoframe/components-env","last_synced_at":"2025-07-02T03:36:59.020Z","repository":{"id":178172199,"uuid":"659859410","full_name":"autoframe/components-env","owner":"autoframe","description":"Autoframe Envoirement tools","archived":false,"fork":false,"pushed_at":"2023-07-02T22:28:24.000Z","size":18,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-11T10:12:57.663Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/autoframe.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-06-28T18:07:47.000Z","updated_at":"2023-07-02T21:44:05.000Z","dependencies_parsed_at":null,"dependency_job_id":"59796d08-328f-47a0-9526-2711000f300a","html_url":"https://github.com/autoframe/components-env","commit_stats":null,"previous_names":["autoframe/components-env"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/autoframe/components-env","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/autoframe%2Fcomponents-env","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/autoframe%2Fcomponents-env/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/autoframe%2Fcomponents-env/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/autoframe%2Fcomponents-env/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/autoframe","download_url":"https://codeload.github.com/autoframe/components-env/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/autoframe%2Fcomponents-env/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263071244,"owners_count":23409255,"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":"2025-02-18T01:38:36.192Z","updated_at":"2025-07-02T03:36:58.991Z","avatar_url":"https://github.com/autoframe.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Autoframe is a low level framework that is oriented on SOLID flexibility\n\n[![Build Status](https://github.com/autoframe/components-env/workflows/PHPUnit-tests/badge.svg?branch=main)](https://github.com/autoframe/components-env/actions?query=branch:main)\n[![License: The 3-Clause BSD License](https://img.shields.io/github/license/autoframe/components-env)](https://opensource.org/license/bsd-3-clause/)\n![Packagist Version](https://img.shields.io/packagist/v/autoframe/components-env?label=packagist%20stable)\n[![Downloads](https://img.shields.io/packagist/dm/autoframe/components-env.svg)](https://packagist.org/packages/autoframe/components-env)\n\n*PHP Environment Tools, Autoframe Framework*\n\nNamespace:\n- Autoframe\\Components\\Env\n- **AfrEnv::getInstance()-\u003eisDev() returns true if APP_ENV is null**\n- **APP_ENV is not mandatory but recommended AfrEnv::getInstance()-\u003esetInlineEnvVar('APP_ENV', 'DEV');**\n\nClasses:\n- class AfrEnv extends AfrSingletonAbstractClass implements AfrEnvInterface\n  - setWorkDir(string $sDir)\n  - readEnv(int $iCacheSeconds, array $aExtraEnvDirsFiles = [])\n    * iCacheSeconds is the number of cache seconds before expire. Use zero for no cache\n    * aExtraEnvDirsFiles to add extra env directories and .env files\n  - readEnvPhpFile(string $sFilePath)\n  - setInlineEnvVar(string $sKey, $mData)\n  - - populate inline keys\n  - required(array $aKeys): AfrEnvValidatorInterface\n  - ifPresent(array $aKeys): AfrEnvValidatorInterface\n  - unrequire(array $aKeys): AfrEnvValidatorInterface\n  - - unset required or ifPresent\n  - registerEnv(bool $bMutableOverwrite = false, bool $bRegisterPutEnv = false)\n  - - will populate $_ENV, $_SERVER and getenv()\n  - getEnv(string $sKey = '') single key or all registered values\n  - - storage only inside class without $_ENV, $_SERVER or getenv()\n  - flush()  reset and clear all\n  - isProduction()\n  - isStaging()\n  - isLocal()\n  - isDev()\n- class AfrEnvParserClass extends AfrSingletonAbstractClass implements AfrEnvParserInterface\n    - parseStr\n    - parseFile\n- class AfrEnvValidatorClass implements AfrEnvValidatorInterface\n    - reusable validator using closures\n    - required(array $aKeys)\n    - ifPresent(array $aKeys)\n    - customClosure(callable $fX)\n    - allowedValues(array $aAllowed)\n    - validateAll(array $aDataSet): bool\n    - reset()\n    - reset(array $aKeys)\n    - unrequire(array $aKeys)\n    - isInteger()\n    - isFloat()\n    - isBoolean()\n    - isArray()\n    - isString()\n    - isDateTime()\n    - notEmpty()\n\n---\n\n# AfrEnv\n\n    // GENERAL\n    $oEnv = AfrEnv::getInstance()-\u003esetWorkDir(__DIR__);\n    $oEnv-\u003ereadEnv(0); //load env files from __DIR__ without cache\n    $oEnv-\u003ereadEnv(60); //cache loaded env file for 60 seconds\n    $oEnv-\u003esetInlineEnvVar('FOO', 'BAR'); //set *[FOO]=BAR\n    \n    $oEnv-\u003egetEnv('APP_ENV'); //get env key\n    $oEnv-\u003egetEnv(); //get all env keys as array\n\n    $oEnv-\u003eregisterEnv($bMutableOverwrite = true, $bRegisterPutEnv = true);\n    // populate $_SERVER, $_ENV and getenv()\n    $oEnv-\u003eflush(); //total reset for class,cache, except superglobals are stil available\n\n---\n\n    // INCLUDES PHP FILE THAT CONTAINS return array(...);\n    $oEnv = AfrEnv::getInstance();\n    $oEnv-\u003ereadEnvPhpFile(path);\n    $oEnv-\u003egetEnv('FROM_PHP_FILE');\n\n---\n\n    // Validator: REQUIRED or throw error on register or access\n    $oEnv = AfrEnv::getInstance();\n    $oEnv-\u003erequired(['APP_ENV','SECRET']);\n    $oEnv-\u003erequired(['NUMBER_INT'])-\u003eisInteger();\n    $oEnv-\u003eifPresent(['NUMBER_FLOAT'])-\u003eisFloat();\n    $oEnv-\u003eifPresent(['SOMENTHING'])-\u003enotEmpty();\n    $oEnv-\u003eifPresent(['SOME_DATE_TIME'])-\u003eisDateTime();\n    $oEnv-\u003eunrequire(['NUMBER_INT']);\n    $oEnv-\u003egetEnv('SECRET');\n\n---\n\n    // CUSTOM APP_ENV\n    $oEnv = AfrEnv::getInstance();\n    $this-\u003eifPresent(['APP_ENV'])-\u003eallowedValues([\n      'DEV',\n      'PRODUCTION',\n      'STAGING',\n      'LOCAL',\n      'CUSTOM',\n    ]);\n    $oEnv-\u003esetInlineEnvVar('APP_ENV', 'CUSTOM');\n    echo $oEnv-\u003egetEnv('APP_ENV'); //prints CUSTOM\n\t\n---\n\n    // xet : set / get\n    $oEnv = AfrEnv::getInstance();\n    $oEnv-\u003exetAfrEnvParser(AfrEnvParserInterface $oEnvParser = null): AfrEnvParserInterface\n    $oEnv-\u003exetAfrEnvValidator(AfrEnvValidatorInterface $oValidator = null): AfrEnvValidatorInterface\n    $oEnv-\u003exetFileList(AfrDirTraversingFileListInterface $oFileList = null): AfrDirTraversingFileListInterface\n    $oEnv-\u003exetOverWrite(AfrOverWriteInterface $oOverWrite = null): AfrOverWriteInterface\n    $oEnv-\u003exetExportArray(AfrArrExportArrayAsStringInterface $oExportArray = null): AfrArrExportArrayAsStringInterface\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fautoframe%2Fcomponents-env","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fautoframe%2Fcomponents-env","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fautoframe%2Fcomponents-env/lists"}