{"id":20187948,"url":"https://github.com/commonphp/config-php","last_synced_at":"2025-07-29T05:34:28.520Z","repository":{"id":223134425,"uuid":"758791069","full_name":"commonphp/config-php","owner":"commonphp","description":"The PHP Configuration Driver for CommonPHP facilitates the use of PHP files for application configuration, supporting both loading and saving of configurations with robust error handling.","archived":false,"fork":false,"pushed_at":"2024-02-18T14:55:36.000Z","size":4,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-03-10T07:47:49.458Z","etag":null,"topics":["commonphp","config-driver","configuration-management","php-configuration","php-driver"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/commonphp.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}},"created_at":"2024-02-17T04:56:01.000Z","updated_at":"2024-02-18T14:55:53.000Z","dependencies_parsed_at":null,"dependency_job_id":"d3da1770-77b8-478b-be5e-362f621e1034","html_url":"https://github.com/commonphp/config-php","commit_stats":null,"previous_names":["commonphp/config-php"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/commonphp/config-php","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/commonphp%2Fconfig-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/commonphp%2Fconfig-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/commonphp%2Fconfig-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/commonphp%2Fconfig-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/commonphp","download_url":"https://codeload.github.com/commonphp/config-php/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/commonphp%2Fconfig-php/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267633672,"owners_count":24118777,"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","status":"online","status_checked_at":"2025-07-29T02:00:12.549Z","response_time":2574,"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":["commonphp","config-driver","configuration-management","php-configuration","php-driver"],"created_at":"2024-11-14T03:26:45.210Z","updated_at":"2025-07-29T05:34:28.319Z","avatar_url":"https://github.com/commonphp.png","language":"PHP","readme":"# PHP Configuration Driver for CommonPHP\n\nThis library introduces the PHP configuration driver, `PhpConfigurationDriver`, as part of the CommonPHP Configuration Management ecosystem. It extends the functionality of CommonPHP by allowing applications to seamlessly load and save configurations using PHP files.\n\n## Features\n\n- **Load PHP Configurations**: Simplifies the process of reading PHP files and converting them into associative arrays for easy access within PHP applications.\n- **Save Configurations as PHP**: Offers the ability to serialize PHP associative arrays back into PHP format, preserving the structure and hierarchies.\n- **Structured Error Handling**: Incorporates detailed exception handling to manage potential parsing and file operation errors effectively.\n- **Support for Nested Structures**: Through a custom implementation, it supports the representation of nested structures within PHP files, providing greater flexibility in configuration management.\n\n## Installation\n\nUse Composer to integrate both the Configuration Manager and the PHP driver into your project:\n\n```\ncomposer require comphp/config\ncomposer require comphp/config-php\n```\n\n## Usage\n\nTo utilize the PHP driver with the Configuration Manager, first ensure the `DriverManager` is configured to recognize the PHP driver:\n\n```php\nuse CommonPHP\\Drivers\\DriverManager;\nuse CommonPHP\\Configuration\\Drivers\\PhpConfigurationDriver\\PhpConfigurationDriver;\n\n$driverManager = new DriverManager();\n$driverManager-\u003eenable(PhpConfigurationDriver::class);\n```\n\nUpon configuration, the `PhpConfigurationDriver` will be automatically used for `.php` file extensions, thanks to the `#[ConfigurationDriverAttribute('php')]` annotation.\n\n### Loading a Configuration File\n\n```php\n$configManager-\u003eloadDriver(PhpConfigurationDriver::class);\n$config = $configManager-\u003eget('path/to/configuration.php');\n```\n\n### Saving a Configuration File\n\nAfter loading the driver as described above, modifications can be saved back to the PHP file:\n\n```php\n$config-\u003edata['newSection'] = ['newKey' =\u003e 'newValue'];\n$config-\u003esave(); // Persists the changes to 'path/to/configuration.php'\n```\n\n## Exception Handling\n\nThe driver includes specific exception handling for common issues such as:\n\n- **ConfigurationException**: Thrown for errors related to PHP file parsing or when the file format does not meet the expected structure.\n- **General Exceptions**: For file read/write operations or parsing failures.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcommonphp%2Fconfig-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcommonphp%2Fconfig-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcommonphp%2Fconfig-php/lists"}