Download the PHP package comphp/config without Composer
On this page you can find all versions of the php package comphp/config. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download comphp/config
More information about comphp/config
Files in comphp/config
Package config
Short Description Provides read/write access to configuration files
License MIT
Informations about the package config
CommonPHP Configuration Manager
The CommonPHP Configuration Manager (comphp/config
) is a flexible and robust library designed to simplify the management of configuration files in PHP applications. It leverages the power of dynamic driver loading and custom behaviors to provide a highly adaptable solution for application configuration.
Features
- Dynamic Driver Support: Easily extendable to support various configuration file formats through custom drivers.
- Behavior Customization: Control how the system handles duplicate file extensions and unsupported save operations with configurable behaviors.
- Exception Handling: Comprehensive exception handling for precise error tracking and management.
- Attribute and Contract-Based Configuration: Utilize PHP attributes and interfaces for defining configuration drivers, ensuring a clear and structured approach.
Installation
Use Composer to install the Configuration Manager:
Basic Usage
Refer to the examples/general-usage.php
file for a detailed example. Here's a quick overview:
-
Define a Configuration Driver: Implement the
ConfigurationDriverContract
in your driver class. Optionally, use theConfigurationDriverAttribute
to specify supported file extensions. -
Load and Use the Configuration Manager:
- Saving Configurations: If your driver supports saving, you can persist modifications:
Customizing Behavior
Customize how the Configuration Manager handles certain scenarios through properties:
- Duplicate Extension Behavior: Decide how to handle when multiple drivers claim the same file extension.
- Configuration Cannot Save Behavior: Define behavior for when a configuration cannot be saved (e.g., driver doesn't support saving).
Creating Custom Drivers
Implement the ConfigurationDriverContract
interface in your driver class and optionally use the ConfigurationDriverAttribute
to specify which file extensions your driver supports.
Handling Exceptions
The library defines a range of exceptions for fine-grained error handling, from driver load failures to access denied scenarios. Catch these exceptions to handle different error conditions gracefully.
Contributing
Contributions to the CommonPHP Configuration Manager are welcome. Please follow the repository's contributing guidelines to submit bug reports, feature requests, or pull requests.
License
The CommonPHP Configuration Manager is open-sourced software licensed under the MIT license.