{"id":22147540,"url":"https://github.com/myerscode/config","last_synced_at":"2026-02-25T00:36:25.799Z","repository":{"id":48225776,"uuid":"333397468","full_name":"myerscode/config","owner":"myerscode","description":"A PHP utility that enables the creation of multi file, cross-referencing configuration maps","archived":false,"fork":false,"pushed_at":"2025-02-03T22:09:03.000Z","size":52,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-10T14:06:00.757Z","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/myerscode.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-01-27T11:24:41.000Z","updated_at":"2025-02-03T22:09:07.000Z","dependencies_parsed_at":"2022-08-23T12:20:48.008Z","dependency_job_id":"f0d250c7-cd2c-4c6e-bf4b-9e229b103398","html_url":"https://github.com/myerscode/config","commit_stats":{"total_commits":24,"total_committers":1,"mean_commits":24.0,"dds":0.0,"last_synced_commit":"607cbffd94f8608efa8f1469fb48f609a425f0f4"},"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/myerscode/config","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/myerscode%2Fconfig","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/myerscode%2Fconfig/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/myerscode%2Fconfig/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/myerscode%2Fconfig/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/myerscode","download_url":"https://codeload.github.com/myerscode/config/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/myerscode%2Fconfig/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263421460,"owners_count":23464012,"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-12-01T23:18:17.787Z","updated_at":"2026-02-25T00:36:20.732Z","avatar_url":"https://github.com/myerscode.png","language":"PHP","readme":"#  Config\n\u003e A PHP utility that creates a configuration object from multi file, cross-referencing php array maps or yaml files\n\n[![Latest Stable Version](https://poser.pugx.org/myerscode/config/v/stable)](https://packagist.org/packages/myerscode/config)\n[![Total Downloads](https://poser.pugx.org/myerscode/config/downloads)](https://packagist.org/packages/myerscode/config)\n[![License](https://poser.pugx.org/myerscode/config/license)](https://packagist.org/packages/myerscode/config)\n![Tests](https://github.com/myerscode/config/actions/workflows/tests.yml/badge.svg?branch=main)\n[![codecov](https://codecov.io/gh/myerscode/config/graph/badge.svg?token=YR0YHVERNV)](https://codecov.io/gh/myerscode/config)\n\n## Why this package is helpful?\n\nThis package will allow you to build a config object, that you can simply retrieve values from. You manage configuration \nacross multiple PHP or YAML files, with the ability to cross-reference properties in order to build up complex values.\n\n## Install\n\nYou can install this package via composer:\n\n``` bash\ncomposer require myerscode/config\n```\n\n## Usage\n\n### Creating a Config Store\nTo get started ll you need to do is you need to create a `Config` instance and start loading data into files into it.\n\n```php\n$config = new Config();\n\n$config-\u003eloadFiles([\n'config/app.php',\n'config/db.yaml',\n]);\n\n$config-\u003eloadFile('config/cache.php');\n\n$config-\u003eloadData(['api_key' =\u003e 'abc123']);\n\n// example config object\n[\n    'name' =\u003e 'myerscode',\n    'db_name' =\u003e 'myerscode_db',\n    'api_key' =\u003e 'abc123',\n]\n```\n\n### Namespaced Configuration\nBy default, config from files will be merged recursivly when loaded in. If you want to \ngive each file a top level namespace call the `loadFilesWithNamespace` and `loadFileWithNamespace` methods to have each\nfile be loaded into a namespace using their filename\n```php\n$config = new Config();\n\n$config-\u003eloadFilesWithNamespace([\n'config/app.php',\n'config/db.yaml',\n]);\n\n$config-\u003eloadFileWithNamespace('config/cache.php');\n\n// example config object\n[\n    'app' =\u003e [...],\n    'db' =\u003e [...],\n    'cache' =\u003e [...],\n]\n```\n\n\n### Retrieving a value\nRetrieve a single value from the store by using the `value` method and passing in a key.\n\nUsing `dot notation` you can access deep values of a config element, or retrieve the entire\nobject by calling its top level namespace.\n\n```php\n$config-\u003evalue('app.name');\n\n$config-\u003evalue('app');\n\n$config-\u003evalue('api_key');\n```\n\n### Get all store value\nGet all the values from the store as an array using the `values` method.\n```php\n$config-\u003evalues();\n```\n\n### Accessing the store\nAccessing the values directly is done by calling the `store` method.\n```php\n$store = $config-\u003estore();\n```\n\n## Config Syntax\nA basic config file, is a PHP file that will just return an array or a YAML file.\n\n```php\n// app.config.php\nreturn [\n    'name' =\u003e 'Fred Myerscough',\n    'settings' =\u003e [\n        'a',\n        'b',\n        'c'\n    ],\n];\n```\n\n### Cross Referencing Values\n\n```php \n// app.config.php\nreturn [\n    'name' =\u003e 'myerscode',\n    'env' =\u003e 'myerscode',\n];\n\n// db.config.php\nreturn [\n    'db' =\u003e [\n        'setting' =\u003e [\n            'name' =\u003e '${env}_${name}_db',\n        ]\n    ],\n    'db_name' =\u003e '${db.config.name}'\n];\n```\n\n## Issues and Contributing\n\nWe are very happy to receive pull requests to add functionality or fixes.\n\nBug reports and feature requests can be submitted on the [Github Issue Tracker](https://github.com/myerscode/config/issues).\n\nPlease read the Myerscode [contributing](https://github.com/myerscode/docs/blob/main/CONTRIBUTING.md) guide for information on our Code of Conduct.\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE) for more information.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmyerscode%2Fconfig","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmyerscode%2Fconfig","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmyerscode%2Fconfig/lists"}