Download the PHP package wilkques/config without Composer

On this page you can find all versions of the php package wilkques/config. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package config

Config for PHP

TESTS Latest Stable Version License

English | 繁體中文

Load PHP/JSON/YAML config files from a directory tree into a single, dot-notation-accessible config store, kept compatible all the way back to PHP 5.3.

Requirements

Installation

Usage

  1. Add a config file (path default ./config, any nesting depth — subdirectories become nested keys)

    Or json

    Or yaml
    ※need php yaml extension

  2. Add PHP code in file

Config::make() (and the config() global helper) always return the same shared instance, resolved through Wilkques\Container\Container — calling ->boot() once is enough, every later config() call sees the same booted config.

Dot notation & nested files

A config file's name becomes its top-level key, and subdirectories nest the same way — a file at config/database/mysql.php is read as database.mysql. getItem()/setItem() accept dot-separated keys to reach into that nesting:

API Reference

Every method below has a runnable example, taken from the test suite (tests/Units/Higher/ConfigTest.php / tests/Units/Lower/ConfigTest.php) and verified on PHP 5.3.10, 7.4, and 8.3.

Method Description Example
make() (static) Resolve the shared Config instance via the container. Config::make();
setConfigRootPath($configRootPath) / setPath($path) Set the directory boot() scans for config files (default ./config). $config->setPath('/app/config');
getConfigRootPath() Get the currently-configured config root directory. $config->getConfigRootPath(); // '/app/config'
boot() Scan the config root (recursively) and load every .php/.json/.yaml/.yml file found. $config->boot();
all() / items() Get every loaded config item. $config->all(); // ['database' => [...], ...]
getItem($key, $default = null) Get a config value by dot-notation key. $config->getItem('database.mysql.host'); // '127.0.0.1'
setItem($key, $value) Set a config value by dot-notation key. $config->setItem('database.mysql.host', '127.0.0.1');
setConfig($config) Replace the entire loaded config array. $config->setConfig(['abc' => 'efg']);
withConfig($config) Recursively merge an array into the existing config. $config->withConfig(['abc' => 'efg']);
isEmptyConfig() / isNotEmptyConfig() Determine whether any config has been loaded/set. $config->isEmptyConfig(); // true before boot()
yaml($path) Parse a YAML file directly (throws if ext-yaml isn't loaded). $config->yaml('/app/config/app.yaml');

Magic property, array, and iterator access

Config also implements ArrayAccess, Countable, IteratorAggregate, and JsonSerializable, plus __get/__set — all equivalent shortcuts for getItem()/setItem()/all().

Access style Example
Magic property $config->foo = 'bar'; $config->foo; // 'bar'
Array access $config['foo'] = 'bar'; $config['foo']; // 'bar'
count($config) Counts the top-level config items.
foreach ($config as $key => $value) Iterates the top-level config items.
json_encode($config) Serializes all().

Testing

License

MIT


All versions of config with dependencies

PHP Build Version
Package Version
Requires php Version >=5.3
wilkques/container Version *
wilkques/php-helper Version ^6.1.0
wilkques/filesystem Version ^2.1.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package wilkques/config contains the following files

Loading the files please wait ...