{"id":22425355,"url":"https://github.com/phppkg/config","last_synced_at":"2025-07-09T01:37:27.761Z","repository":{"id":43443208,"uuid":"119495248","full_name":"phppkg/config","owner":"phppkg","description":"PHP Config load, management, get, set and more. Supports INI,JSON,YAML,TOML,NEON,PHP format file","archived":false,"fork":false,"pushed_at":"2024-11-11T02:29:34.000Z","size":89,"stargazers_count":12,"open_issues_count":1,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-11-11T03:24:08.692Z","etag":null,"topics":["config","configs","configuration","configuration-management","json","php","php-config","toml"],"latest_commit_sha":null,"homepage":"https://phppkg.github.io/config/","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/phppkg.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":"2018-01-30T06:53:10.000Z","updated_at":"2024-11-11T02:29:37.000Z","dependencies_parsed_at":"2024-11-11T06:00:29.911Z","dependency_job_id":null,"html_url":"https://github.com/phppkg/config","commit_stats":{"total_commits":46,"total_committers":3,"mean_commits":"15.333333333333334","dds":0.06521739130434778,"last_synced_commit":"562bbb20f76a4b49381ec4d148e49c805c26c1f2"},"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phppkg%2Fconfig","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phppkg%2Fconfig/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phppkg%2Fconfig/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phppkg%2Fconfig/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/phppkg","download_url":"https://codeload.github.com/phppkg/config/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228356390,"owners_count":17907191,"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":["config","configs","configuration","configuration-management","json","php","php-config","toml"],"created_at":"2024-12-05T19:13:53.392Z","updated_at":"2025-07-09T01:37:27.748Z","avatar_url":"https://github.com/phppkg.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Config\n\n[![License](https://img.shields.io/packagist/l/phppkg/config.svg?style=flat-square)](LICENSE)\n[![Php Version](https://img.shields.io/packagist/php-v/phppkg/config?maxAge=2592000)](https://packagist.org/packages/phppkg/config)\n[![Latest Stable Version](http://img.shields.io/packagist/v/phppkg/config.svg)](https://packagist.org/packages/phppkg/config)\n[![Actions Status](https://github.com/phppkg/config/workflows/Unit-Tests/badge.svg)](https://github.com/phppkg/config/actions)\n\n🗂 Config load, management, merge, get, set and more.\n\n- Config data load, management\n- Support load multi config data, will auto merge\n- Supports INI,JSON,YAML,TOML,NEON,PHP format file\n- Support for exporting configuration data to file\n- Language data management\n\n\u003e **[中文说明](README.zh-CN.md)**\n\n## Install\n\n**composer**\n\n```bash\ncomposer require phppkg/config\n```\n\n## Usage\n\ncreate and load config data. load multi file, will auto merge data.\n\n```php\nuse PhpPkg\\Config\\ConfigBox;\n\n$config = ConfigBox::new();\n$config-\u003eloadFromFiles([\n    __DIR__ . '/test/testdata/config.ini',\n    __DIR__ . '/test/testdata/config.neon',\n    __DIR__ . '/test/testdata/config.yml',\n    __DIR__ . '/test/testdata/config.toml',\n]);\n```\n\n### Created in other ways\n\n```php\nuse PhpPkg\\Config\\ConfigBox;\n\n$config = ConfigBox::newFromFiles([\n    // ... config file list\n]);\n\n$config-\u003eloadIniFile('path/to/my.ini')\n```\n\n### More load methods\n\n- `loadFromFiles(array $filePaths, string $format = '')`\n- `loadFromStrings(string $format, string ...$strings)`\n- `loadFromSteam(string $format, resource $stream)`\n- `loadIniFile(string $filepath)`\n- `loadJsonFile(string $filepath)`\n- `loadJson5File(string $filepath)`\n- `loadYamlFile(string $filepath)`\n- `loadPhpFile(string $filepath)`\n\n### Dump data\n\n```php\n// dump config\nvdump($config-\u003egetData());\n```\n\n**Output**:\n\n```php\nCALL ON PhpPkg\\ConfigTest\\ConfigBoxTest(24):\narray(7) {\n  [\"name\"]=\u003e string(6) \"inhere\"\n  [\"age\"]=\u003e int(89)\n  [\"atIni\"]=\u003e string(6) \"value0\"\n  [\"arr0\"]=\u003e array(3) {\n    [0]=\u003e string(2) \"ab\"\n    [1]=\u003e int(23)\n    [2]=\u003e string(2) \"de\"\n  }\n  [\"map0\"]=\u003e array(2) {\n    [\"key0\"]=\u003e string(4) \"val0\"\n    [\"key1\"]=\u003e string(4) \"val1\"\n  }\n  [\"atNeon\"]=\u003e string(6) \"value1\"\n  [\"atYaml\"]=\u003e string(6) \"value2\"\n  [\"atToml\"]=\u003e string(6) \"val at toml\"\n}\n```\n\n## Get value\n\n```php\n/** @var PhpPkg\\Config\\ConfigBox $config */\n$config-\u003egetInt('age'); // int(89)\n$config-\u003egetString('name'); // string('inhere')\n$config-\u003eget('arr0');\n$config-\u003eget('map0');\n\n// get value by key-path.\n$config-\u003egetInt('arr0.1'); // int(23)\n$config-\u003egetString('map0.key0'); // string('val0')\n```\n\n## Set value\n\n```php\n/** @var PhpPkg\\Config\\ConfigBox $config */\n$config-\u003eset('name', 'INHERE');\n$config-\u003eset('map0.key0', 'new value');\n\n// set multi at once\n$config-\u003esets([\n    'key1' =\u003e 'value1',\n    'key2' =\u003e 'value2',\n    // ...\n]);\n```\n\n## Export to file\n\nExport config data to file.\n\n```php\nuse PhpPkg\\Config\\ConfigBox;\n\n/** @var ConfigBox $config */\n$config-\u003eexportTo('/path/to/file.json');\n$config-\u003eexportTo('/path/to/my.conf', ConfigBox::FORMAT_YAML);\n```\n\n## PHPPkg Projects\n\n- [phppkg/config](https://github.com/phppkg/config) - 🗂 Config load, management, merge, get, set and more.\n- [phppkg/easytpl](https:://github.com/phppkg/easytpl) - ⚡️ Simple and fastly template engine for PHP\n- [phppkg/http-client](https:://github.com/phppkg/http-client) - An easy-to-use HTTP client library for PHP\n- [phppkg/ini](https:://github.com/phppkg/ini) - 💪 An enhanced `INI` format parser written in PHP.\n- [phppkg/jenkins-client](https:://github.com/phppkg/jenkins-client) - Designed to interact with Jenkins CI using its API.\n- [phppkg/phpgit](https:://github.com/phppkg/phpgit) - A Git wrapper library for PHP\n\n## License\n\n[MIT](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphppkg%2Fconfig","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphppkg%2Fconfig","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphppkg%2Fconfig/lists"}