Download the PHP package phower/config without Composer
On this page you can find all versions of the php package phower/config. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download phower/config
More information about phower/config
Files in phower/config
Package config
Short Description Simplified methods to handle configuration data in PHP.
License MIT
Homepage https://github.com/phower/config
Informations about the package config
Phower Config
Simplified methods to handle configuration data in PHP.
Requirements
Phower Config requires:
Instalation
Add Phower Config to any PHP project using Composer:
Getting Started
An associative array can be used as configuration data to be handled on any application.
Include configuration
Optionally configuration data can be read from a plain PHP script returning an array:
Interface methods
Because we implemented ArrayAccess Interface and Magic Methods it's also possible to access configuration data in different styles:
Normalized key names
Since key names are normalized internally it's possible to relax on naming conventions:
Note that normalized key names can ride to duplicates which should be avoided by using some sort of naming convention when Phower Config instances are created. E.g always use snake-case or camel case on array element keys.
Read-only mode
By default instances are created read-only which means they can't be changed after creation. However this behaviour can be changed in two ways:
Note the argument of
readOnly
method is optional. When omitted the method returns the state of read-only mode; otherwise it sets its state to TRUE or FALSE.
Allow-override mode
Like in read-only mode it's also possible to control overrides in Phower Config instances. Initially overrides are not allowed but this can be changed like previously:
Note the argument of
allowOverride
method is optional. When omitted the method returns the state of allow-override mode; otherwise it sets its state to TRUE or FALSE.Obviously overrides can only be done with read-only mode set to FALSE.
Changing configuration
When required to change configuration after creation that can be done by setting or removing keys:
Like in getting key values from configuration array access interface and magic methods are also available:
Checking configuration
To check if a given key exists in configuration another method is available:
Advanced Usage
In some situations may be required to export a configuration instance to array or merge
another config object into the current instance. To provide these needs methods toArray
and merge
are available:
Running Tests
Tests are available in a separated namespace and can run with PHPUnit in the command line:
Coding Standards
Phower code is written under PSR-2 coding style standard. To enforce that CodeSniffer tools are also provided and can run as:
Reporting Issues
In case you find issues with this code please open a ticket in Github Issues at https://github.com/phower/config/issues.
Contributors
Open Source is made of contribuition. If you want to contribute to Phower please follow these steps:
- Fork latest version into your own repository.
- Write your changes or additions and commit them.
- Follow PSR-2 coding style standard.
- Make sure you have unit tests with full coverage to your changes.
- Go to Github Pull Requests at https://github.com/phower/config/pulls and create a new request.
Thank you!
Changes and Versioning
All relevant changes on this code are logged in a separated log file.
Version numbers follow recommendations from Semantic Versioning.
License
Phower code is maintained under The MIT License.