Download the PHP package alius/config without Composer
On this page you can find all versions of the php package alius/config. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package config
Alius Config
Alius Config is just a simple composer package, all it can do is include php array files.
Never commit any sensitive information into your version control!
Basic usage:
Multiple files, directories
You can include multiple files:
One or more directories (includes the subdirectories and files recursively):
All of the files must use php as extension and they must return array.
Last file wins
If you include two files with the same variable, the last file always wins:
It's a good idea to name your files starting with numbers:
Get the source file of a variable
Including lots of files could be confusing so you can get the source file of a variable:
Required variables
You can mark a variables required, if none of the included files has this variable then an exception will be thrown:
Get the variables in one array
You can get an array with all the variables:
Error thrown, if:
- any of the files doesn't exist or not readable or has extension other than php
- if you try to get a non-existing variable ( or )
- when a required variable is not found in any of the included files
The point is that it should fail fast so you can fix everything before you commit your changes or deploy.
Recommended usage
Never commit any sensitive information into your version control!
You should create a directory for all of your non-sensitive data, and another one for sensitive data (and exclude that one from version control).
For example:
Or you can still use dotenv or similar for sensitive data, for example Laravel’s env function with defaults:
What’s wrong with dotenv?
Nothing, but sometimes it’s just not enough.
With this package you can include files conditionally, override variables, you can use bool, int, float, arrays, constants, Closures, even objects or resources.
Or you can extend it, create your DatabaseConfig class so you can inject it as a dependency.