Download the PHP package vshf/php-config without Composer
On this page you can find all versions of the php package vshf/php-config. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download vshf/php-config
More information about vshf/php-config
Files in vshf/php-config
Package php-config
Short Description PHP configuration system to handle app settings
License MIT
Informations about the package php-config
VSHF PHP Config Manager
VSHF PHP Config Manager is a settings/configuration manager for PHP applications. It provides functionality to handle settings and resources with their properties.
Usage
To use the VSHF Config Manager, you need to instantiate the Config
class:
You can also initialize it with settings:
Contexts
The default setting context is the app context. When initializing with settings, they will be added to this context.
You can hydrate different contexts later on:
This will create an internal settings tree with the following structure:
Resources and properties
In the case of having a collection of resources and their properties, where the properties can be considered as settings for each resource, you can use the Config Manager to handle them.
For example, if you have a collection of services with the isPriced property, you can observe the value of this property for different services.
To hydrate with a resource collection:
Observers
Each setting must have its corresponding Observer, which implements the ObserverInterface
. An observer can handle one or more settings.
To register an observer:
Resource property observers
Similarly, each resource property must have its PropertyObserver, which implements the PropertyObserverInterface
. An observer can handle one or more properties.
To register a PropertyObserver:
Get and save
To retrieve a setting:
To save a setting:
Resource properties
To retrieve a property of a given resource:
To save a property of a given resource:
To retrieve a given resource with all its properties:
Setting dependencies
A setting or a resource property can depend on one or more other settings, even from different contexts.
To set dependencies, the dependencies()
method of the observer must return a Dependency object.
In this example, if settingB is equal to certainValue, then settingA is properly returned. Otherwise, NULL is returned.
It's important to note that NULL should not be a default/proper setting value.
Complex dependencies
Dependencies can be complex and involve logical operators such as AND and OR. You can construct complex dependencies using the Dependency object.
License
This project is open-source software licensed under the MIT license