PHPackages                             slaxweb/config - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. slaxweb/config

ActiveLibrary[Framework](/categories/framework)

slaxweb/config
==============

Config component for the SlaxWeb Framework

0.3.0(9y ago)11.1k18MITPHPPHP &gt;=7.0.0

Since Mar 20Pushed 9y ago2 watchersCompare

[ Source](https://github.com/SlaxWeb/Config)[ Packagist](https://packagist.org/packages/slaxweb/config)[ RSS](/packages/slaxweb-config/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependencies (3)Versions (7)Used By (8)

Config
======

[](#config)

[![Build Status](https://camo.githubusercontent.com/6cf9fc1eccc4fcb3e974557e06eff7beec0c8ded93ee7566ca2caa5530ddb990/68747470733a2f2f7472617669732d63692e6f72672f536c61785765622f436f6e6669672e7376673f6272616e63683d302e312e30)](https://travis-ci.org/SlaxWeb/Config)

Config component of the SlaxWeb\\Framework handles loading and parsing of configuration options from multiple sources. Currently only file based resources are supported, and can be in 3 formats, PHP, XML, or Yaml.

Requirements
============

[](#requirements)

- PHP 7.0+
- desperado/xml-bundle 0.1.\* package - for XML configuration handler
- symfony/yaml 3.0.\* package - for Yaml configuration handler
- pimple/pimple 3.0.\* package - to use the provided service provider

Installation
============

[](#installation)

Easiest form of installation is through [composer](https://getcomposer.org/), just require the package in your *composer.json* file:

```
{
    "require": {
        "slaxweb/config": "~0.1"
    }
}
```

And this should get you started to use the Config component, with the PHP configuration handler. If you want to use XML or Yaml configuration providers, you need to install their respective required packages with composer (see Requirements).

Usage
=====

[](#usage)

The Config component provides you a *Factory* class for easier instantiation. To get started, simply call the **init** static method of the Factory with the correct constant for the configuration handler you want to use, and the path to your configuration file location. Configuration handler constants:

- \\SlaxWeb\\Config\\Container::PHP\_CONFIG\_HANDLER
- \\SlaxWeb\\Config\\Container::XML\_CONFIG\_HANDLER
- \\SlaxWeb\\Config\\Container::YAML\_CONFIG\_HANDLER

```
$config = \SlaxWeb\Config\Factory::init(
    \SlaxWeb\Config\Container::PHP_CONFIG_HANDLER,
    "/path/to/configuration/"
);
```

The factory will automatically instantiate the correct configuration handler and inject it to the Config class, along with your provided configuration resource location.

Manipulating configuration
--------------------------

[](#manipulating-configuration)

The Container class implements *ArrayAccess* and must be used as such. Retrieving, setting, removing and checking for existence, is done like if it were on an array. For loading of new configuration resources, the **load**method is provided. Example PHP configuration file:

```
