{"id":35256862,"url":"https://github.com/sunchayn/simple-2way-config","last_synced_at":"2026-04-09T04:02:11.541Z","repository":{"id":62525846,"uuid":"157292080","full_name":"sunchayn/simple-2way-config","owner":"sunchayn","description":"Simple 2 way (read/write) php-based configuration","archived":false,"fork":false,"pushed_at":"2018-11-14T20:13:32.000Z","size":17,"stargazers_count":9,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2026-03-21T23:28:25.497Z","etag":null,"topics":["config","configuration","php","two-way-config"],"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/sunchayn.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-11-12T23:35:28.000Z","updated_at":"2023-09-25T22:54:35.000Z","dependencies_parsed_at":"2022-11-02T10:31:21.515Z","dependency_job_id":null,"html_url":"https://github.com/sunchayn/simple-2way-config","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/sunchayn/simple-2way-config","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sunchayn%2Fsimple-2way-config","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sunchayn%2Fsimple-2way-config/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sunchayn%2Fsimple-2way-config/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sunchayn%2Fsimple-2way-config/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sunchayn","download_url":"https://codeload.github.com/sunchayn/simple-2way-config/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sunchayn%2Fsimple-2way-config/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31584818,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-08T14:31:17.711Z","status":"online","status_checked_at":"2026-04-09T02:00:06.848Z","response_time":112,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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","two-way-config"],"created_at":"2025-12-30T08:06:21.010Z","updated_at":"2026-04-09T04:02:11.536Z","avatar_url":"https://github.com/sunchayn.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"## mazentouati/simple-2way-config\n\n[![GitHub (pre-)release](https://img.shields.io/github/release-pre/mazentouati/simple-2way-config.svg)](https://github.com/mazentouati/simple-2way-config/releases/tag/0.1.0)\n[![Build Status](https://travis-ci.org/mazentouati/simple-2way-config.svg?branch=master)](https://travis-ci.org/mazentouati/simple-2way-config)\n[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/mazentouati/simple-2way-config/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/mazentouati/simple-2way-config/?branch=master)\n[![Codecov branch](https://img.shields.io/codecov/c/github/mazentouati/simple-2way-config/master.svg?style=flat-square)](https://codecov.io/gh/mazentouati/simple-2way-config)\n[![StyleCI](https://styleci.io/repos/157292080/shield)](https://styleci.io/repos/157292080)\n[![Maintainability](https://api.codeclimate.com/v1/badges/8f71ba0353635c7f4350/maintainability)](https://codeclimate.com/github/mazentouati/simple-2way-config/maintainability)\n[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](./LICENSE)\n\nSimple 2 way configuration is a php-based read and write configuration library. It's suitable for applications that require the use of file system to store preferences or configuration.\n\n## Installation\nwe recommend installing this package through  [composer](http://getcomposer.org/) :\n\n```bash\ncomposer require mazentouati/simple-2way-config\n```\n\n## Usage\nThe simplest way to use it is through the package's factory. The factory's required parameter is the path of the directory that holds your config files.\n\n```php\nuse MazenTouati\\Simple2wayConfig\\S2WConfigFactory;\n\n$config = S2WConfigFactory::create( __DIR__ . '/demo' );\n```\n\nNow you can access to a config value using dot notation '{filename}.path.to.value'\n```php\n$host = $config-\u003eget('database.drivers.mysql.host');\n```\n*Note: your config file should be an array-based configuration, check this [example](#configuration-file-formats)*\n\n## API\n\n\u003c!-- DOCS START --\u003e\n\nthe config API implements the `S2WConfigInterface`.\n\nthe examples shown below will assume that you already assigned your config to a variable called `$config`\n\n### get(string $path, mixed $default = null)\nGet a value using dot-notation path using this convention `{filename}.path.to.value`\n```php\n$config-\u003eget('database.drivers.mysql.host');\n```\noptionally you can pass a default value to return when it find nothing, by default it returns `null`\n```php\necho $config-\u003eget('somewhere.where.are.you', 'here');\n\u003e here\n```\n\n### set(string $path, mixed $value)\nUpdate a value in the runtime configuration.\n\n*Note: if it's unable to find the config's filename it will create a new key for that filename in the runtime instance. The same for values, if there's any missing part in the dot path it will automatically create it in the runtime instance.*\n\n```php\n$config-\u003eset('database.drivers.mysql.host', '127.0.0.1');\n```\n\n### sync(mixed $specificConfiguration = false)\nSyncs the runtime configuration with the source file\n```php\n$config-\u003esync();\n```\nby default it will sync all files, though you can pass a specific file to sync\n\n```php\n$config-\u003esync('database');\n```\nusing `sync` will create a backup file to stay safe if something wrong happen.\nthe backup will create alongside the original file holding this name `{original_file_name}.backup.php`.\nif the backup fails due to a lack of permission ( it uses PHP `copy` function) it will throw an exception `S2WConfigException`.\nTo avoid any ugly expections errors you can use `sync` this way\n\n```php\nuse MazenTouati\\Simple2wayConfig\\S2WConfigException;\n...\ntry {\n    $config-\u003esync();\n} catch (S2WConfigException $e) {\n    die($e-\u003egetMessage());\n}\n```\nin case of expection this code will print something like\n\n`Configuration sync is unable to save a backup for { path_to_directory\\database.php }, please check your permissions`\n\n*Note: this method will sync any news values or updated values you made using the `set` method. Even if you set inexistent config file into the runtime configuration, using `set`, this method will create that file for you. Use it with caution if you don't want any unwanted behavior*\n\u003c!-- DOCS END --\u003e\n# Configuration File Formats\nThe configuration file must be a valid php file and return a valid array.\n\n```php\n\u003c?php\nreturn [\n    'driver' =\u003e 'mysql',\n    'drivers' =\u003e [\n        'mysql' =\u003e [\n            'host' =\u003e 'your_host',\n            'dbname' =\u003e 'your_database',\n            'user' =\u003e 'your_user',\n            'password' =\u003e 'your_password',\n        ],\n    ],\n];\n```\n## Contributing\n\nPlease check [the guide](./CONTRIBUTING.md)\n\n## LICENSE\n\n\u003e \u0026copy; [MIT](./LICENSE) | 2018, mazentouati/simple-2way-config\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsunchayn%2Fsimple-2way-config","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsunchayn%2Fsimple-2way-config","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsunchayn%2Fsimple-2way-config/lists"}