Download the PHP package xy2z/lite-config without Composer
On this page you can find all versions of the php package xy2z/lite-config. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download xy2z/lite-config
More information about xy2z/lite-config
Files in xy2z/lite-config
Package lite-config
Short Description A lightweight PHP static class with zero dependencies.
License MIT
Informations about the package lite-config
LiteConfig
A lightweight PHP static class with zero dependencies.
Supports multiple configs and multidimensional arrays.
Built-in support for PHP, INI and JSON files. Also supports YAML and anything else you can parse to an array, see custom_handler() below.
Requirements
- PHP 7.0 +
Install
Examples
Array
Directory
Single file
YAML
To load a single file as YAML see below. If you need to use loadDir()
with yaml (or other) files, then read about "Custom Handler" below.
Custom Handler
A custom handler can be used for file extensions other than the built in (.php, .json and .ini). This will automatically work when using the loadFile()
and loadDir()
functions.
Here's how you use the static custom_handler()
function if you want YAML support.
If you want to modify the existing handling of all files, you can overwrite the complete getFileContent()
function in your child class, which is used by loadDir()
and loadFile()
.
Public Methods
get(string $key, $default = null)
Get value of key.all()
Returns a complete array.exists(string $key)
Does key exist?loadDir(string $path, bool $prefix_filename = false, string $prefix = null)
Loads all files in dir.loadFile(string $path, bool $prefix_filename = false, string $custom_prefix = null)
Load a single file.loadArray(array $array, string $prefix = null)
Loads a php array.
Public Properties
ini_process_sections
(bool, defaulttrue
) - Argument used in file_parse_ini()ini_scanner_mode
(int, defaultINI_SCANNER_TYPED
) - Argument used in file_parse_ini()ignore_unsupported_filestypes
(bool, defaulttrue
) - If true, files with unsupported extensions will be ignored. If false, an exception will be thrown.