Download the PHP package simplecomplex/config without Composer
On this page you can find all versions of the php package simplecomplex/config. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download simplecomplex/config
More information about simplecomplex/config
Files in simplecomplex/config
Package config
Short Description Simple Cache like configuration interfaces; ini-files as source, cache as store.
License MIT
Homepage https://github.com/simplecomplex/php-config
Informations about the package config
Config
- Installation
- Requirements
Simple and sectioned configuration interfaces
is basically PSR-16 Simple Cache without time-to-live.
There's a key and a value.
That principle isn't optimal for general use, unless you like real long and complex key names.
Splits the item key into 'section' plus 'key', facilitating a more organized structure.
The immediate benefit is that you can namespace all items that belong to a particular library.
The section-key pattern can be implemented and utilized in two manners:
- concatenation: the configuration setters and getters simply concatenate section and key
-
listing: the section is a list of keys, you can access the whole section as well as a particular key
also allows for short-term keeping items in memory, via methods and .
Implementations
Environment variable based
is a simple abstraction of server environment variables.
a sectioned implementation, using concatenation.
Ini-files as source, cache as store
The ini-file based classes parse ini-files, and save to cache stores.
They read recursively from their ini-file paths. That allows one to clone and use ini-files from multiple version control repositories.
Ini-files are so old-school...
Aye, but the ini format is less error-prone than JSON, YAML, what-not.
The syntax is so simple it's hard to make mistakes. And operations people are used to ini-files.
Cache layer
is SimpleComplex Cache .
Cache store names are prefixed with
Beware of conflict; do not prefix other cache stores that way.
Types of ini-based configuration
is not sectioned. Simple but probably not that useful.
is a powerful general usage implementation.
Reads ini-files from a base path and an override path.
Keep development/production invariant variables (ini-files) in the base path.
Let operations keep production variables in the override path.
Using the list-principle - and fully supporting and - is optimal for accessing many/all keys of a section within a limited procedure.
a sectioned implementation, using concatenation.
Optimal for types of configuration one expects to access keys of diverse sections in an unpredictable manner,
but still want the organisational benefit of sections; many but exact cache reads.
SimpleComplex Locale uses this config class for localized texts.
Abstraction
The **** class is an abstraction of sectioned configuration.
In this package it extends .
In an extending package it could be some other sectioned config implementation.
CLI interface
**** delivers CLI commands for setting, getting and deleting config items.
And commands for refreshing and exporting full configuration stores.
It exposes instances, via the class.
The other config classes are not accessible via CLI.
Global config
defaults to deliver an instance named 'global'.
A typical system could probably benefit from a single config instance for the bulk of items.
Since the whole thing runtime is cache based, there's no performance reason for using multiple instances.
Dependency injection container ID: config
Recommendation: access (and thus instantiate) the global config via DI container ID 'config'.
See SimpleComplex Utils .
Example
CLI commands
Installation
Create a 'conf' directory alongside the document root dir.
Like:
Create 'base' and 'override' paths within the 'conf', like:
For the 'global' config store, place or symlink or git clone your system's
.ini configuration files under the 'base' and 'override' paths
using file extension (= ).
Like:
If that directory structure isn't suitable, do either:
- supply **** constructor with a 'paths' argument
- extend and override it's class constant
Requirements
- PHP >=7.0
- SimpleComplex Cache
- SimpleComplex Utils
Suggestions
All versions of config with dependencies
simplecomplex/utils Version ^1.8 || ^2.0 || dev-develop
simplecomplex/cache Version ^1.3 || dev-develop