{"id":16676503,"url":"https://github.com/jaxwilko/simple-config","last_synced_at":"2025-10-30T21:30:17.969Z","repository":{"id":56997066,"uuid":"217620930","full_name":"jaxwilko/simple-config","owner":"jaxwilko","description":"A simple fluent interface for creating php config files","archived":true,"fork":false,"pushed_at":"2024-09-24T03:48:38.000Z","size":11,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-19T22:47:43.534Z","etag":null,"topics":["configuration-management","php","php7"],"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/jaxwilko.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":"2019-10-25T22:03:09.000Z","updated_at":"2024-09-24T03:48:54.000Z","dependencies_parsed_at":"2022-08-21T14:10:51.166Z","dependency_job_id":null,"html_url":"https://github.com/jaxwilko/simple-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/jaxwilko%2Fsimple-config","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaxwilko%2Fsimple-config/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaxwilko%2Fsimple-config/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaxwilko%2Fsimple-config/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jaxwilko","download_url":"https://codeload.github.com/jaxwilko/simple-config/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239060464,"owners_count":19574969,"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-management","php","php7"],"created_at":"2024-10-12T13:10:42.701Z","updated_at":"2025-10-30T21:30:17.644Z","avatar_url":"https://github.com/jaxwilko.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003e Archived: use [winter/laravel-config-writer](https://github.com/wintercms/laravel-config-writer) instead.\n\n# SimpleConfig\n\nThis package aims to provide a simple interface for creating php config files.\n\n### Installation\n\nAdd the package to your project via:\n\n```\ncomposer require jaxwilko/simple-config\n```\n\n### Usage\n\n```php\n\u003c?php\n\nuse SimpleConfig\\Compiler;\nuse SimpleConfig\\Section;\n\n$compiler = new Compiler();\n$section = new Section();\n$section-\u003etitle = 'Database';\n$section-\u003ekey = 'database';\n$section-\u003ecomment = 'This is where your database config goes.';\n$section-\u003evalue = ['mysql' =\u003e ['host' =\u003e 'localhost']];\n$compiler-\u003eaddSection($section);\necho $compiler-\u003erender();\n```\n\nWould return:\n\n```php\n\u003c?php\n\nreturn [\n    /*\n    |----------------------------------------\n    | Database\n    |----------------------------------------\n    | This is where your database config goes.\n    |\n    */\n\n    'database' =\u003e [\n        'mysql' =\u003e [\n            'host' =\u003e 'localhost',\n        ],\n    ],\n];\n```\n\nA simpler way of achieving the same thing would be:\n\n```php\n\u003c?php\n\n$compiler = new Compiler();\n$compiler-\u003eaddSection(new Section([\n    'title'     =\u003e 'Database',\n    'key'       =\u003e 'database',\n    'comment'   =\u003e 'This is where your database config goes.',\n    'value'     =\u003e ['mysql' =\u003e ['host' =\u003e 'localhost']],\n]));\necho $compiler-\u003erender();\n```\n\nEverything can be omitted, for example just having a comment and title:\n\n```php\n$compiler = new Compiler();\n$compiler-\u003eaddSection(new Section([\n    'title' =\u003e 'Database',\n    'comment' =\u003e 'This is where your database config goes.',\n]));\necho $compiler-\u003erender();\n```\n\nWill return:\n\n```php\n\u003c?php\n\nreturn [\n    /*\n    |----------------------------------------\n    | Database\n    |----------------------------------------\n    | This is where your database config goes.\n    |\n    */\n\n];\n```\n\nOr, without a comment and title:\n\n```php\n\u003c?php\n\n$compiler = new Compiler();\n$compiler-\u003eaddSection(new Section([\n    'key' =\u003e 'database',\n    'value' =\u003e ['mysql' =\u003e ['host' =\u003e 'localhost']],\n]));\necho $compiler-\u003erender();\n```\n\nWill return:\n\n```php\n\u003c?php\n\nreturn [\n    'database' =\u003e [\n        'mysql' =\u003e [\n            'host' =\u003e 'localhost',\n        ],\n    ],\n];\n```\n\nMultiple sections can be added via chaining:\n\n```php\n\u003c?php\n\n$compiler-\u003eaddSection(new Section([\n        'title' =\u003e 'Section one',\n        'key' =\u003e 'section_one',\n        'comment' =\u003e 'This is a section',\n        'value' =\u003e [\n            'foo' =\u003e 'bar',\n            'bar' =\u003e [\n                'foo'\n            ]\n        ]\n    ]))\n    -\u003eaddSection(new Section([\n        'title' =\u003e 'Section two',\n        'key' =\u003e 'section_two',\n        'comment' =\u003e 'This is another section',\n        'value' =\u003e [\n            'bar' =\u003e 'foo',\n            'foo' =\u003e [\n                'bar'\n            ]\n        ]\n    ]));\n```\n\nFunctions can be passed in by prefixing the method with `@@`. E.g.\n\n```php\n\u003c?php\n\n$compiler-\u003eaddSection(new Section([\n    'title' =\u003e 'Section',\n    'key' =\u003e 'section',\n    'comment' =\u003e 'This is a section',\n    'value' =\u003e [\n        'foo' =\u003e '@@env(\\'VALUE\\')',\n    ]\n]));\n```\n\nWill result in:\n\n```php\n\u003c?php\n\nreturn [\n    /*\n    |----------------------------------------\n    | Section\n    |----------------------------------------\n    | This is a section\n    |\n    */\n\n    'section' =\u003e [\n        'foo' =\u003e env('VALUE'),\n    ],\n];\n```\n\nCompiler options can be set via:\n\n```php\n\u003c?php\n\n// define the comment length\n$compiler-\u003eoption('length', 80);\n// use spaces over tabs\n$compiler-\u003eoption('tabs', false);\n// define the indentation length\n$compiler-\u003eoption('indent', 4);\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjaxwilko%2Fsimple-config","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjaxwilko%2Fsimple-config","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjaxwilko%2Fsimple-config/lists"}