{"id":13668789,"url":"https://github.com/laruence/yaconf","last_synced_at":"2025-05-14T20:04:16.882Z","repository":{"id":10009822,"uuid":"12046312","full_name":"laruence/yaconf","owner":"laruence","description":"A PHP Persistent Configurations Container","archived":false,"fork":false,"pushed_at":"2025-02-25T05:03:42.000Z","size":148,"stargazers_count":1047,"open_issues_count":1,"forks_count":183,"subscribers_count":77,"default_branch":"master","last_synced_at":"2025-04-01T10:06:24.546Z","etag":null,"topics":["c","configuration-management","php","yaconf"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/laruence.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":"2013-08-12T02:34:04.000Z","updated_at":"2025-03-27T19:28:24.000Z","dependencies_parsed_at":"2024-06-28T05:21:34.087Z","dependency_job_id":"6641fefc-36ad-41e4-8339-7412164e2734","html_url":"https://github.com/laruence/yaconf","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/laruence%2Fyaconf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/laruence%2Fyaconf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/laruence%2Fyaconf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/laruence%2Fyaconf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/laruence","download_url":"https://codeload.github.com/laruence/yaconf/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247829490,"owners_count":21002995,"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":["c","configuration-management","php","yaconf"],"created_at":"2024-08-02T08:00:49.542Z","updated_at":"2025-04-08T11:06:53.987Z","avatar_url":"https://github.com/laruence.png","language":"C","funding_links":[],"categories":["C","配置 Configuration","PHP 扩展","框架组件","配置( Configuration )"],"sub_categories":["无服务器的 Serverless","PRC"],"readme":"# Yaconf - Yet Another Configurations Container\n[![Build status](https://ci.appveyor.com/api/projects/status/hbrmch6np854b4b5/branch/master?svg=true)](https://ci.appveyor.com/project/laruence/yaconf/branch/master) [![Build Status](https://github.com/laruence/yaconf/workflows/integrate/badge.svg)](https://github.com/laruence/yaconf/actions?query=workflow%3Aintegrate)\n\nA PHP Persistent Configurations Container\n\n### Requirement\n- PHP 7+\n\n### Introduction\n\nYaconf is a configurations container, it parses ini files, store the result in PHP when PHP is started, configurations live in the whole PHP lifecycle, which makes it very fast.\n\n### Features\n- Fast, Light\n- Zero-copy while accesses configurations\n- Support sections, sections inheritance\n- Configurations reload automatically after changed\n\n### Install\n\n#### Compile Yaconf in Linux\nYaconf is an PECL extension, thus you can simply install it by:\n\n```\n$pecl install yaconf\n```\nOr you can compile it by your self:\n```\n$ /path/to/php7/bin/phpize\n$ ./configure --with-php-config=/path/to/php7/bin/php-config\n$ make \u0026\u0026 make install\n```\n\n### Runtime configuration\n\n- yaconf.directory\n```\n  Path to directory which all ini configuration files are placed in\n```\n- yaconf.check_delay\n```\n  In which interval Yaconf will detect ini file's change(by directory's mtime),\n  if it is set to zero, you have to restart php to reloading configurations.\n```\n\n### APIs\n\n````php\nmixed Yaconf::get(string $name, mixed $default = NULL)\nbool  Yaconf::has(string $name)\n````\n\n### Example\n\n#### Directory\n\nAssuming we place all configurations files in /tmp/yaconf/, thus we added this into php.ini\n```\nyaconf.directory=/tmp/yaconf\n````\n\n#### INI Files\n\nAssuming there are two files in /tmp/yaconf\n\nfoo.ini\n````ini\nname=\"yaconf\"                  ;string\nyear=2015                      ;number\nfeatures[]=\"fast\"              ;map\nfeatures.1=\"light\"\nfeatures.plus=\"zero-copy\"\nfeatures.constant=PHP_VERSION  ;PHP constants\nfeatures.env=${HOME}           ;Enviorment variables\n````\nand bar.ini\n````ini\n[base]\nparent=\"yaconf\"\nchildren=\"NULL\"\n\n[children:base]               ;inherit from section \"base\"\nchildren=\"set\"\n````\n#### Run\nlets retrieve the configurations from Yaconf\n\n##### foo.ini\n````php\nphp7 -r 'var_dump(Yaconf::get(\"foo\"));'\n/*\narray(3) {\n  [\"name\"]=\u003e\n  string(6) \"yaconf\"\n  [\"year\"]=\u003e\n  string(4) \"2015\"\n  [\"features\"]=\u003e\n  array(5) {\n    [0]=\u003e\n    string(4) \"fast\"\n    [1]=\u003e\n    string(5) \"light\"\n    [\"plus\"]=\u003e\n    string(9) \"zero-copy\"\n    [\"constant\"]=\u003e\n    string(9) \"7.0.0-dev\"\n    [\"env\"] =\u003e\n    string(16) \"/home/huixinchen\"\n  }\n}\n*/\n````\nAs you can see, Yaconf supports string, map(array), ini, env variable and PHP constants.\n\nYou can also access configurations like this:\n````php\nphp7 -r 'var_dump(Yaconf::get(\"foo.name\"));'\n//string(6) \"yaconf\"\n\nphp7 -r 'var_dump(Yaconf::get(\"foo.features.1\"));'\n//string(5) \"light\"\n\nphp7 -r 'var_dump(Yaconf::get(\"foo.features\")[\"plus\"]);'\n//string(9) \"zero-copy\"\n````\n\n##### bar.ini\nNow let's see the sections and sections inheritance:\n````php\nphp7 -r 'var_dump(Yaconf::get(\"bar\"));'\n/*\narray(2) {\n  [\"base\"]=\u003e\n  array(2) {\n    [\"parent\"]=\u003e\n    string(6) \"yaconf\"\n    [\"children\"]=\u003e\n    string(4) \"NULL\"\n  }\n  [\"children\"]=\u003e\n  array(2) {\n    [\"parent\"]=\u003e\n    string(6) \"yaconf\"\n    [\"children\"]=\u003e\n    string(3) \"set\"\n  }\n}\n*/\n````\n\nChildren section has inherited values in base sections, and children is able to override the values they want.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flaruence%2Fyaconf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flaruence%2Fyaconf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flaruence%2Fyaconf/lists"}