{"id":13405088,"url":"https://github.com/thephpleague/config","last_synced_at":"2025-06-18T08:08:19.859Z","repository":{"id":42039475,"uuid":"372302963","full_name":"thephpleague/config","owner":"thephpleague","description":"Simple yet expressive schema-based configuration library for PHP apps","archived":false,"fork":false,"pushed_at":"2025-06-16T00:19:16.000Z","size":143,"stargazers_count":535,"open_issues_count":4,"forks_count":15,"subscribers_count":7,"default_branch":"main","last_synced_at":"2025-06-16T03:51:19.144Z","etag":null,"topics":["config","configuration","hacktoberfest","php","schema"],"latest_commit_sha":null,"homepage":"https://config.thephpleague.com","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thephpleague.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":".github/CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":".github/SECURITY.md","support":".github/SUPPORT.MD","governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":"colinodell","custom":["https://www.colinodell.com/sponsor","https://www.paypal.me/colinpodell/10.00"]}},"created_at":"2021-05-30T19:50:32.000Z","updated_at":"2025-06-15T11:24:49.000Z","dependencies_parsed_at":"2023-09-26T04:59:31.111Z","dependency_job_id":"2b4856ba-1f8b-42d2-88bd-2a90233d8084","html_url":"https://github.com/thephpleague/config","commit_stats":{"total_commits":68,"total_committers":9,"mean_commits":7.555555555555555,"dds":"0.36764705882352944","last_synced_commit":"708b87250055f20a21cc6dbe232369b79a71a4fa"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/thephpleague/config","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thephpleague%2Fconfig","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thephpleague%2Fconfig/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thephpleague%2Fconfig/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thephpleague%2Fconfig/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thephpleague","download_url":"https://codeload.github.com/thephpleague/config/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thephpleague%2Fconfig/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260214669,"owners_count":22975782,"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","configuration","hacktoberfest","php","schema"],"created_at":"2024-07-30T19:01:55.579Z","updated_at":"2025-06-18T08:08:14.818Z","avatar_url":"https://github.com/thephpleague.png","language":"PHP","funding_links":["https://github.com/sponsors/colinodell","https://www.colinodell.com/sponsor","https://www.paypal.me/colinpodell/10.00"],"categories":["PHP"],"sub_categories":[],"readme":"# league/config\n\n[![Latest Version](https://img.shields.io/packagist/v/league/config.svg?style=flat-square)](https://packagist.org/packages/league/config)\n[![Total Downloads](https://img.shields.io/packagist/dt/league/config.svg?style=flat-square)](https://packagist.org/packages/league/config)\n[![Software License](https://img.shields.io/badge/License-BSD--3-brightgreen.svg?style=flat-square)](LICENSE)\n[![Build Status](https://img.shields.io/github/workflow/status/thephpleague/config/Tests/main.svg?style=flat-square)](https://github.com/thephpleague/config/actions?query=workflow%3ATests+branch%3Amain)\n[![Coverage Status](https://img.shields.io/scrutinizer/coverage/g/thephpleague/config.svg?style=flat-square)](https://scrutinizer-ci.com/g/thephpleague/config/code-structure)\n[![Quality Score](https://img.shields.io/scrutinizer/g/thephpleague/config.svg?style=flat-square)](https://scrutinizer-ci.com/g/thephpleague/config)\n[![Sponsor development of this project](https://img.shields.io/badge/sponsor%20this%20package-%E2%9D%A4-ff69b4.svg?style=flat-square)](https://www.colinodell.com/sponsor)\n\n**league/config** helps you define nested configuration arrays with strict schemas and access configuration values with dot notation.  It was created by [Colin O'Dell][@colinodell].\n\n## 📦 Installation\n\nThis project requires PHP 7.4 or higher.  To install it via [Composer] simply run:\n\n```bash\ncomposer require league/config\n```\n\n## 🧰️ Basic Usage\n\nThe `Configuration` class provides everything you need to define the configuration structure and fetch values:\n\n```php\nuse League\\Config\\Configuration;\nuse Nette\\Schema\\Expect;\n\n// Define your configuration schema\n$config = new Configuration([\n    'database' =\u003e Expect::structure([\n        'driver' =\u003e Expect::anyOf('mysql', 'postgresql', 'sqlite')-\u003erequired(),\n        'host' =\u003e Expect::string()-\u003edefault('localhost'),\n        'port' =\u003e Expect::int()-\u003emin(1)-\u003emax(65535),\n        'ssl' =\u003e Expect::bool(),\n        'database' =\u003e Expect::string()-\u003erequired(),\n        'username' =\u003e Expect::string()-\u003erequired(),\n        'password' =\u003e Expect::string()-\u003enullable(),\n    ]),\n    'logging' =\u003e Expect::structure([\n        'enabled' =\u003e Expect::bool()-\u003edefault($_ENV['DEBUG'] == true),\n        'file' =\u003e Expect::string()-\u003edeprecated(\"use logging.path instead\"),\n        'path' =\u003e Expect::string()-\u003eassert(function ($path) { return \\is_writeable($path); })-\u003erequired(),\n    ]),\n]);\n\n// Set the values, either all at once with `merge()`:\n$config-\u003emerge([\n    'database' =\u003e [\n        'driver' =\u003e 'mysql',\n        'port' =\u003e 3306,\n        'database' =\u003e 'mydb',\n        'username' =\u003e 'user',\n        'password' =\u003e 'secret',\n    ],\n]);\n\n// Or one-at-a-time with `set()`:\n$config-\u003eset('logging.path', '/var/log/myapp.log');\n\n// You can now retrieve those values with `get()`.\n// Validation and defaults will be applied for you automatically\n$config-\u003eget('database');        // Fetches the entire \"database\" section as an array\n$config-\u003eget('database.driver'); // Fetch a specific nested value with dot notation\n$config-\u003eget('database/driver'); // Fetch a specific nested value with slash notation\n$config-\u003eget('database.host');   // Returns the default value \"localhost\"\n$config-\u003eget('logging.path');    // Guaranteed to be writeable thanks to the assertion in the schema\n\n// If validation fails an `InvalidConfigurationException` will be thrown:\n$config-\u003eset('database.driver', 'mongodb');\n$config-\u003eget('database.driver'); // InvalidConfigurationException\n\n// Attempting to fetch a non-existent key will result in an `InvalidConfigurationException`\n$config-\u003eget('foo.bar');\n\n// You could avoid this by checking whether that item exists:\n$config-\u003eexists('foo.bar'); // Returns `false`\n```\n\n## 📓 Documentation\n\nFull documentation can be found at [config.thephpleague.com][docs].\n\n## 💭 Philosophy\n\nThis library aims to provide a **simple yet opinionated** approach to configuration with the following goals:\n\n- The configuration should operate on **arrays with nested values** which are easily accessible\n- The configuration structure should be **defined with strict schemas** defining the overall structure, allowed types, and allowed values\n- Schemas should be defined using a **simple, fluent interface**\n- You should be able to **add and combine schemas but never modify existing ones**\n- Both the configuration values and the schema should be **defined and managed with PHP code**\n- Schemas should be **immutable**; they should never change once they are set\n- Configuration values should never define or influence the schemas\n\nAs a result, this library will likely **never** support features like:\n\n- Loading and/or exporting configuration values or schemas using YAML, XML, or other files\n- Parsing configuration values from a command line or other user interface\n- Dynamically changing the schema, allowed values, or default values based on other configuration values\n\nIf you need that functionality you should check out other libraries like:\n\n- [symfony/config]\n- [symfony/options-resolver]\n- [hassankhan/config]\n- [consolidation/config]\n- [laminas/laminas-config]\n\n## 🏷️ Versioning\n\n[SemVer](http://semver.org/) is followed closely. Minor and patch releases should not introduce breaking changes to the codebase.\n\nAny classes or methods marked `@internal` are not intended for use outside this library and are subject to breaking changes at any time, so please avoid using them.\n\n## 🛠️ Maintenance \u0026 Support\n\nWhen a new **minor** version (e.g. `1.0` -\u003e `1.1`) is released, the previous one (`1.0`) will continue to receive security and critical bug fixes for *at least* 3 months.\n\nWhen a new **major** version is released (e.g. `1.1` -\u003e `2.0`), the previous one (`1.1`) will receive critical bug fixes for *at least* 3 months and security updates for 6 months after that new release comes out.\n\n(This policy may change in the future and exceptions may be made on a case-by-case basis.)\n\n## 👷‍️ Contributing\n\nContributions to this library are **welcome**! We only ask that you adhere to our [contributor guidelines] and avoid making changes that conflict with our Philosophy above.\n\n## 🧪 Testing\n\n```bash\ncomposer test\n```\n\n## 📄 License\n\n**league/config** is licensed under the BSD-3 license.  See the [`LICENSE.md`][license] file for more details.\n\n## 🗺️  Who Uses It?\n\nThis project is used by [league/commonmark][league-commonmark].\n\n[docs]: https://config.thephpleague.com/\n[@colinodell]: https://www.twitter.com/colinodell\n[Composer]: https://getcomposer.org/\n[PHP League]: https://thephpleague.com\n[symfony/config]: https://symfony.com/doc/current/components/config.html\n[symfony/options-resolver]: https://symfony.com/doc/current/components/options_resolver.html\n[hassankhan/config]: https://github.com/hassankhan/config\n[consolidation/config]: https://github.com/consolidation/config\n[laminas/laminas-config]: https://docs.laminas.dev/laminas-config/\n[contributor guidelines]: https://github.com/thephpleague/config/blob/main/.github/CONTRIBUTING.md\n[license]: https://github.com/thephpleague/config/blob/main/LICENSE.md\n[league-commonmark]: https://commonmark.thephpleague.com\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthephpleague%2Fconfig","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthephpleague%2Fconfig","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthephpleague%2Fconfig/lists"}