{"id":13805806,"url":"https://github.com/DavidePastore/Slim-Config","last_synced_at":"2025-05-13T21:31:29.484Z","repository":{"id":42828109,"uuid":"53088130","full_name":"DavidePastore/Slim-Config","owner":"DavidePastore","description":"A file configuration loader that supports PHP, INI, XML, JSON, and YML files for the Slim Framework. It internally uses https://github.com/hassankhan/config.","archived":false,"fork":false,"pushed_at":"2022-03-26T18:41:25.000Z","size":267,"stargazers_count":33,"open_issues_count":1,"forks_count":7,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-12T06:17:48.299Z","etag":null,"topics":["config","ini","json","middleware","php","slim-framework","xml","yaml"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DavidePastore.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-03-03T22:13:46.000Z","updated_at":"2025-01-22T21:27:01.000Z","dependencies_parsed_at":"2022-08-21T05:40:27.547Z","dependency_job_id":null,"html_url":"https://github.com/DavidePastore/Slim-Config","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DavidePastore%2FSlim-Config","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DavidePastore%2FSlim-Config/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DavidePastore%2FSlim-Config/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DavidePastore%2FSlim-Config/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DavidePastore","download_url":"https://codeload.github.com/DavidePastore/Slim-Config/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254031023,"owners_count":22002688,"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","ini","json","middleware","php","slim-framework","xml","yaml"],"created_at":"2024-08-04T01:01:05.064Z","updated_at":"2025-05-13T21:31:28.252Z","avatar_url":"https://github.com/DavidePastore.png","language":"PHP","readme":"# Slim Framework Config\n\n[![Latest version][ico-version]][link-packagist]\n[![Build Status][ico-github-actions]][link-github-actions]\n[![Coverage Status][ico-scrutinizer]][link-scrutinizer]\n[![Quality Score][ico-code-quality]][link-code-quality]\n[![Total Downloads][ico-downloads]][link-downloads]\n[![PSR2 Conformance][ico-styleci]][link-styleci]\n\n\nA file configuration loader that supports PHP, INI, XML, JSON, and YML files for the Slim Framework. It internally uses [hassankhan/config][hassankhan-config].\n\n## Install\n\nVia Composer\n\n``` bash\n$ composer require davidepastore/slim-config\n```\n\nRequires Slim 3.0.0 or newer.\n\n## Usage\n\nIn most cases you want to register `DavidePastore\\Slim\\Config` for a single route, however,\nas it is middleware, you can also register it for all routes.\n\n\n### Register per route\n\n```php\n$app = new \\Slim\\App();\n\n// Fetch DI Container\n$container = $app-\u003egetContainer();\n\n// Register provider\n$container['config'] = function () {\n  //Create the configuration\n  return new \\DavidePastore\\Slim\\Config\\Config('config.json');\n};\n\n$app-\u003eget('/api/myEndPoint',function ($req, $res, $args) {\n    //Here you have your configuration\n    $config = $this-\u003econfig-\u003egetConfig();\n    $secret = $config-\u003eget('security.secret');\n})-\u003eadd($container-\u003eget('config'));\n\n$app-\u003erun();\n```\n\n\n### Register for all routes\n\n```php\n$app = new \\Slim\\App();\n\n// Fetch DI Container\n$container = $app-\u003egetContainer();\n\n// Register provider\n$container['config'] = function () {\n  //Create the configuration\n  return new \\DavidePastore\\Slim\\Config\\Config('config.json');\n};\n\n// Register middleware for all routes\n// If you are implementing per-route checks you must not add this\n$app-\u003eadd($container-\u003eget('config'));\n\n$app-\u003eget('/foo', function ($req, $res, $args) {\n  //Here you have your configuration\n  $config = $this-\u003econfig-\u003egetConfig();\n  $secret = $config-\u003eget('security.secret');\n});\n\n$app-\u003epost('/bar', function ($req, $res, $args) {\n  //Here you have your configuration\n  $config = $this-\u003econfig-\u003egetConfig();\n  $ttl = $config-\u003eget('app.timeout', 3000);\n});\n\n$app-\u003erun();\n```\n\n## Where are the benefits?\n\nThe configuration is loaded from the filesystem only when the given route is called in the _per route_ usage. In the other case (_all routes_) the config should be general and used in the whole routes, because it's read in every request.\n\n## Just the tip of the iceberg!\n\nYou can read the [hassankhan/config][hassankhan-config] documentation [here][hassankhan-config] for more info.\n\n## Testing\n\n``` bash\n$ phpunit\n```\n\n## Contributing\n\nPlease see [CONTRIBUTING](CONTRIBUTING.md) for details.\n\n## Credits\n\n- [Davide Pastore](https://github.com/davidepastore)\n\n\n[hassankhan-config]: https://github.com/hassankhan/config\n[ico-version]: https://img.shields.io/packagist/v/DavidePastore/Slim-Config.svg?style=flat-square\n[ico-github-actions]: https://github.com/DavidePastore/Slim-Config/workflows/Continuous%20Integration/badge.svg?branch=master\n[ico-scrutinizer]: https://img.shields.io/scrutinizer/coverage/g/DavidePastore/Slim-Config.svg?style=flat-square\n[ico-code-quality]: https://img.shields.io/scrutinizer/g/davidepastore/Slim-Config.svg?style=flat-square\n[ico-downloads]: https://img.shields.io/packagist/dt/davidepastore/slim-config.svg?style=flat-square\n[ico-styleci]: https://styleci.io/repos/53088130/shield\n\n[link-packagist]: https://packagist.org/packages/davidepastore/slim-config\n[link-github-actions]: https://github.com/DavidePastore/Slim-Config/actions?query=workflow%3A%22Continuous+Integration%22\n[link-scrutinizer]: https://scrutinizer-ci.com/g/DavidePastore/Slim-Config/code-structure\n[link-code-quality]: https://scrutinizer-ci.com/g/DavidePastore/Slim-Config\n[link-downloads]: https://packagist.org/packages/davidepastore/slim-config\n[link-styleci]: https://styleci.io/repos/53088130/\n","funding_links":[],"categories":["Miscellaneous"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FDavidePastore%2FSlim-Config","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FDavidePastore%2FSlim-Config","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FDavidePastore%2FSlim-Config/lists"}