{"id":20672783,"url":"https://github.com/selective-php/config","last_synced_at":"2026-03-07T12:07:21.503Z","repository":{"id":36111480,"uuid":"221549260","full_name":"selective-php/config","owner":"selective-php","description":"Config component, strictly typed","archived":false,"fork":false,"pushed_at":"2025-11-26T18:40:24.000Z","size":45,"stargazers_count":16,"open_issues_count":0,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2026-02-20T05:57:24.210Z","etag":null,"topics":["config","configuration","php","settings","strict-types"],"latest_commit_sha":null,"homepage":"","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/selective-php.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,"zenodo":null}},"created_at":"2019-11-13T20:50:54.000Z","updated_at":"2025-10-06T09:05:36.000Z","dependencies_parsed_at":"2024-06-19T01:47:16.297Z","dependency_job_id":"0a5f2fa6-251e-4883-982c-c1f522db4283","html_url":"https://github.com/selective-php/config","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/selective-php/config","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/selective-php%2Fconfig","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/selective-php%2Fconfig/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/selective-php%2Fconfig/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/selective-php%2Fconfig/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/selective-php","download_url":"https://codeload.github.com/selective-php/config/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/selective-php%2Fconfig/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30212506,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-07T09:02:10.694Z","status":"ssl_error","status_checked_at":"2026-03-07T09:02:08.429Z","response_time":53,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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","php","settings","strict-types"],"created_at":"2024-11-16T20:38:46.976Z","updated_at":"2026-03-07T12:07:21.473Z","avatar_url":"https://github.com/selective-php.png","language":"PHP","readme":"# selective/config\n\nA strictly typed configuration component for PHP. Inspired by [Apache Commons Configuration](https://commons.apache.org/proper/commons-configuration/).\n\n[![Latest Version on Packagist](https://img.shields.io/github/release/selective-php/config.svg)](https://packagist.org/packages/selective/config)\n[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg)](LICENSE)\n[![Build Status](https://github.com/selective-php/config/workflows/build/badge.svg)](https://github.com/selective-php/config/actions)\n[![Coverage Status](https://img.shields.io/scrutinizer/coverage/g/selective-php/config.svg)](https://scrutinizer-ci.com/g/selective-php/config/code-structure)\n[![Quality Score](https://img.shields.io/scrutinizer/quality/g/selective-php/config.svg)](https://scrutinizer-ci.com/g/selective-php/config/?branch=master)\n[![Total Downloads](https://img.shields.io/packagist/dt/selective/config.svg)](https://packagist.org/packages/selective/config/stats)\n\n\n## Requirements\n\n* PHP 8.1 - 8.4\n\n## Installation\n\n```bash\ncomposer require selective/config\n```\n\n## Theory of Operation\n\nYou can use the `Configuration` to read single values from a multidimensional \narray by passing the path to one of the `get{type}()` and `find{type}()` methods. \n\nEach `get*() / find*()` method takes a default value as second argument.\nIf the path cannot be found in the original array, the default is used as return value.\n\nA `get*()` method returns only the declared return type. \nIf the default value is not given and the element cannot be found, an exception is thrown.\n\nA `find*()` method returns only the declared return type or `null`. \nNo exception is thrown if the element cannot be found.\n\n## Usage\n\n```php\n\u003c?php\n\nuse Selective\\Config\\Configuration;\n\n$config = new Configuration([\n    'key1' =\u003e [\n        'key2' =\u003e [\n            'key3' =\u003e 'value1',\n        ]\n    ]\n]);\n\n// Output: value1\necho $config-\u003egetString('key1.key2.key3');\n```\n\n## Slim 4 integration\n\nAdd this dependency injection container definition:\n\n```php\nuse Selective\\Config\\Configuration;\n\n// ...\n\nreturn [\n    // Application settings\n    Configuration::class =\u003e function () {\n        return new Configuration(require __DIR__ . '/settings.php');\n    },\n    \n    // ...\n];\n```\n\n## Examples\n\n### Configuring a database connection\n\nThe settings:\n\n```php\n// Database settings\n$settings['db'] = [\n    'driver' =\u003e 'mysql',\n    'host' =\u003e 'localhost',\n    'username' =\u003e 'root',\n    'database' =\u003e 'test',\n    'password' =\u003e '',\n    'charset' =\u003e 'utf8mb4',\n    'collation' =\u003e 'utf8mb4_unicode_ci',\n    'flags' =\u003e [\n        PDO::ATTR_PERSISTENT =\u003e false,\n        PDO::ATTR_ERRMODE =\u003e PDO::ERRMODE_EXCEPTION,\n    ],\n];\n```\n\nThe container definition:\n\n```php\nuse Selective\\Config\\Configuration;\nuse PDO;\n\nreturn [\n    // ...\n\n    PDO::class =\u003e static function (ContainerInterface $container) {\n        $config = $container-\u003eget(Configuration::class);\n\n        $host = $config-\u003egetString('db.host');\n        $dbname =  $config-\u003egetString('db.database');\n        $username = $config-\u003egetString('db.username');\n        $password = $config-\u003egetString('db.password');\n        $charset = $config-\u003egetString('db.charset');\n        $flags = $config-\u003egetArray('db.flags');\n        $dsn = \"mysql:host=$host;dbname=$dbname;charset=$charset\";\n\n        return new PDO($dsn, $username, $password, $flags);\n    },\n\n    // ...\n\n];\n```\n\n### Injecting the configuration\n\nThe settings:\n\n```php\n$settings['module'] = [\n    'key1' =\u003e 'my-value',\n];\n```\n\nThe consumer class:\n\n```php\n\u003c?php\n\nnamespace App\\Domain\\User\\Service;\n\nuse Selective\\Config\\Configuration;\n\nfinal class Foo\n{\n    private $config;\n\n    public function __construct(Configuration $config)\n    {\n        $this-\u003econfig = $config;\n    }\n\n    public function bar()\n    {\n        $myKey1 = $this-\u003econfig-\u003egetString('module.key1');\n        \n        // ...\n    }\n}\n\n```\n\n## Similar libraries\n\n* https://github.com/laminas/laminas-config\n* https://github.com/hassankhan/config\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%2Fselective-php%2Fconfig","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fselective-php%2Fconfig","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fselective-php%2Fconfig/lists"}