Download the PHP package puzzle/configuration without Composer
On this page you can find all versions of the php package puzzle/configuration. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download puzzle/configuration
More information about puzzle/configuration
Files in puzzle/configuration
Package configuration
Short Description Configuration component
License MIT
Informations about the package configuration
Puzzle-configuration
PHP 7.x users please use puzzle/configuration 4.x PHP 5.6 users please use puzzle/configuration 3.x
Hide configuration implementation behind common interface.
Some advantages :
- Application does not depend upon configuration implementation details
- Application does not have to manage filesystem issues (for filesystem based implementations)
- Application can be easily tested, even for configuration edge cases (missing or wrong configuration values)
- Define configuration as a service in your dependency injection container
QA
Service | Result |
---|---|
CI | |
Scrutinizer | |
Code coverage | |
Packagist |
Installation
Use composer :
Documentation
Configuration as a service
The way the configuration value is read depends on the chosen implementation.
Up to now, 2 implementations are provided :
- Memory (for unit testing purpose)
- Yaml (based on Symfony/Yaml).
For YAML one, means in app.yml file. When you instanciate YamlConfiguration object, you need to provide where yaml files can be found :
Unit testing
Default values
But if is required :
Fallback strategy
Override configuration
If you need some configuration to (partially or not) override another one :
Another example :
You can add as many as configuration instances you want in the stack. The last inserted is the most prioritary.
If you want to add the least prioritary, use the method :
Prefixed configuration
You can use automatic prefix decorator . It can be useful for "namespace like" configurations such as loggers or multiple databases ones.
Changelog
4.x --> 5.x
- Drop php 7 support. Minimal version is 8.0
3.x --> 4.x
-
Drop php 5.6 & 7.0 support. Minimal version is 7.1.0
2.x --> 3.x
- Drop php 5.5 support. Minimal version is 5.6.0
1.x -> 2.x
- Drop php 5.4 support. Minimal version is 5.5.0