Download the PHP package jenner/config without Composer
On this page you can find all versions of the php package jenner/config. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download jenner/config
More information about jenner/config
Files in jenner/config
Package config
Short Description PHP configurations loading
License MIT
Homepage https://github.com/sinergi/config
Informations about the package config
Config
PHP configurations loading library. It is made to enable your application to have different configurations depending on
the environment it is running in. For example, your application can have different configurations for unit tests, development,
staging and production. A good practice would be to not include your production or staging configurations in your version control.
To do this, simply add a .gitignore
file to your configs/environment
directory with the following lines:
Requirements
This library uses PHP 5.3+.
Installation
It is recommended that you install the Config library through composer. To do so, add the following lines to your composer.json
file.
Usage
Setup the configurations directory:
Optionally, you can also setup the environment. Setting up the environment will merge normal configurations with configurations in the environment directory. For example, if you setup the environment to be prod, the configurations from the directory
configs/prod/*
will be loaded on top of the configurations from the directory configs/*
. Consider the following
example:
You can than use the configurations like this:
Getter
The configuration getter uses a simple syntax: file_name.array_key
.
For example:
You can optionally set a default value like this:
You can use the getter to access multidimensional arrays in your configurations:
Setter
Alternatively, you can set configurations from your application code:
You can set entire arrays of configurations:
Examples
See more examples in the examples folder.
Example of a configuration file: