{"id":19005298,"url":"https://github.com/f3ath/pimple-config","last_synced_at":"2026-04-21T11:30:21.139Z","repository":{"id":56980920,"uuid":"83571306","full_name":"f3ath/pimple-config","owner":"f3ath","description":"Simple multi-environment configuration for Pimple with secret storage support","archived":false,"fork":false,"pushed_at":"2017-03-07T10:10:12.000Z","size":16,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-01T19:28:00.927Z","etag":null,"topics":["configuration","php","pimple"],"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/f3ath.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}},"created_at":"2017-03-01T15:41:48.000Z","updated_at":"2018-01-11T09:53:28.000Z","dependencies_parsed_at":"2022-08-21T08:40:43.250Z","dependency_job_id":null,"html_url":"https://github.com/f3ath/pimple-config","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/f3ath%2Fpimple-config","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/f3ath%2Fpimple-config/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/f3ath%2Fpimple-config/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/f3ath%2Fpimple-config/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/f3ath","download_url":"https://codeload.github.com/f3ath/pimple-config/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240027433,"owners_count":19736212,"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":["configuration","php","pimple"],"created_at":"2024-11-08T18:27:03.326Z","updated_at":"2026-04-21T11:30:21.075Z","avatar_url":"https://github.com/f3ath.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PimpleConfig is a simple multi-environment configuration for Pimple/Silex with secret storage support\n## Install\n```\ncomposer install f3ath/pimple-config\n```\n## Configuration structure\n### Environment-specific config\nA config is a file named `\u003cenvironment_name\u003e.php` which returns an array:\n```php\n\u003c?php\n// dev.php\nreturn [\n    'debug' =\u003e true,\n    'foo' =\u003e [\n        'bar' =\u003e 'baz'\n    ]\n];\n```\nTo reduce duplication, here is some sort of \"inheritance\":\n```php\n\u003c?php\n// stage.php\nreturn array_replace_recursive(require __DIR__ . '/common.php', [ // inherit from common config\n    'debug' =\u003e false,\n]);\n```\n### Secret config\nIt is a healthy practice to store sensitive data like passwords outside of the repository. The simplest implementation\nwould be to store such files right on the server. These files may be edited directly, so they should not be php scripts,\nsince it's easy to accidentally remove the `\u003c?php` header and expose their content. A natural choice in\nthis case is JSON. PimpleConfig supports a special `secret_json` key to include such files.\n```php\n\u003c?php\n// prod.php\nreturn array_replace_recursive(require __DIR__ . '/common.php', [ // inherit from common config\n    'secret_json' =\u003e '/etc/my_application/secret.json',\n    'debug' =\u003e false,\n]);\n```\n### Services\nPimple services are configured in the set of files in the `services` directory. In your configuration you define:\n```php\n\u003c?php\n// common.php\nreturn [\n    'services' =\u003e [\n        'application'   =\u003e __DIR__ . '/services/application.php',\n        'storage'       =\u003e __DIR__ . '/services/storage.php',\n        'controllers'   =\u003e __DIR__ . '/services/controllers.php',\n    ],\n];\n```\nA service config is a php script which returns a special function:\n```php\n\u003c?php\n// services/application.php\nreturn function (\\Pimple\\Container $container, array $config, string $env) {\n    $container['hello'] = function () use ($config, $env) {\n        // here you create and return a service the Pimple way\n    };\n};\n```\n## Register the configuration\n\n```php\n   \u003c?php\n   $pimple = new \\Pimple\\Container();\n   $env_name = 'prod';\n   $config_root = '/path-to-config';\n   $pimple-\u003eregister(new \\F3\\PimpleConfig\\Config($config_root, $env_name));\n```\n\nFor more examples see the [unit test](test/ConfigTest.php).\n\n### Contribution\nPlease do!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ff3ath%2Fpimple-config","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ff3ath%2Fpimple-config","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ff3ath%2Fpimple-config/lists"}