PHPackages                             opxcore/config-repository-files - 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. opxcore/config-repository-files

ActiveLibrary

opxcore/config-repository-files
===============================

The OpxCore config repository driver for local file system.

1.0.4(5y ago)115MITPHPPHP ^7.4

Since Dec 29Pushed 5y ago1 watchersCompare

[ Source](https://github.com/opxcore/config-repository-files)[ Packagist](https://packagist.org/packages/opxcore/config-repository-files)[ Docs](https://opxcore.com)[ RSS](/packages/opxcore-config-repository-files/feed)WikiDiscussions main Synced today

READMEChangelog (5)Dependencies (3)Versions (6)Used By (0)

config-repository-files
=======================

[](#config-repository-files)

Config files loader
===================

[](#config-files-loader)

[![Build Status](https://camo.githubusercontent.com/88760ee9baada48b6ce288b94ffc5ed0ac0cb2201b0751bd326ce847236c7e59/68747470733a2f2f7472617669732d63692e636f6d2f6f7078636f72652f636f6e6669672d7265706f7369746f72792d66696c65732e7376673f6272616e63683d6d61696e)](https://travis-ci.com/opxcore/config-repository-files)[![Coverage Status](https://camo.githubusercontent.com/2c0b6500dfb492d6708f725ca909596a8f192899d0c4739ec8cae6ce8c075222/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f6f7078636f72652f636f6e6669672d7265706f7369746f72792d66696c65732f62616467652e737667)](https://coveralls.io/github/opxcore/config-repository-files)[![Latest Stable Version](https://camo.githubusercontent.com/677b8c4cdf681cc1eff46e37349cc681327faba577378719601112d06d5f4356/68747470733a2f2f706f7365722e707567782e6f72672f6f7078636f72652f636f6e6669672d7265706f7369746f72792d66696c65732f762f737461626c65)](https://packagist.org/packages/opxcore/config-repository-files)[![Total Downloads](https://camo.githubusercontent.com/c39aaf61fe8ca3ac8cdc7a6e98dbb6dc1331be41d113cf430d366f29d8adb827/68747470733a2f2f706f7365722e707567782e6f72672f6f7078636f72652f636f6e6669672d7265706f7369746f72792d66696c65732f646f776e6c6f616473)](https://packagist.org/packages/opxcore/config-repository-files)[![License](https://camo.githubusercontent.com/ce9ca35b3e50fda077d8f68bef4d7e2a1378959b6aa3d151ecb39cb30385864b/68747470733a2f2f706f7365722e707567782e6f72672f6f7078636f72652f636f6e6669672d7265706f7369746f72792d66696c65732f6c6963656e7365)](https://packagist.org/packages/opxcore/config-repository-files)

Installing
----------

[](#installing)

```
composer require opxcore/config-repository-files

```

### Standalone usage:

[](#standalone-usage)

```
use OpxCore\Config\ConfigRepositoryFiles;

$configFiles = new ConfigRepositoryFiles($path);
```

### Usage with [container](https://github.com/opxcore/container)

[](#usage-with-container)

```
use OpxCore\Interfaces\ConfigRepositoryInterface;
use OpxCore\Config\ConfigRepositoryFiles;

$container->bind(
    ConfigRepositoryInterface::class,
    ConfigRepositoryFiles::class,
    ['path' => $path]
);

$configFiles = $container->make(ConfigRepositoryInterface::class);

// or

$container->bind(ConfigRepositoryInterface::class, ConfigRepositoryFiles::class);

$configFiles = $container->make(ConfigRepositoryInterface::class, ['path' => $path]);
```

Where `$path` is absolute path to folder with configuration files.

Loading config
--------------

[](#loading-config)

```
$loaded = $configFiles->load($config, $profile, $overrides)
```

Loads array of configurations from path given in constructor. *Config files will be loaded only from specified directory (see `$profile` for more details), no subdirectories will be included.*

`$config` is array with loaded configuration. In case of failure (config directory is not existing or some error occurred while loading files) this variable will not be modified. Otherwise it will contain array of read configs or empty array if config directory is existing but there is no any config files.

`$profile` is profile name of configuration to load. Can be `null`, `'default'`or some string identifier. `null` means config files are placed in directory specified in `$path` in constructor. If `$profile` is `'default'` or any string identifier configs will be loaded from `{$path}/{$profile}` directory.

`$overrides` is profile name to be overridden by `$profile`. It means profile with name `$overrides` will be loaded and then all keys existing in `$profile`will be recursively merged to result. So you can have a default profile and override some values with another profile you need.

`true` will be returned in cases of directory exists and there is no errors reading files
(or if directory exists, but empty). If directory is not existing or any error occurred `false` will be returned.

Saving config
-------------

[](#saving-config)

Not implemented yet.

Config file content
-------------------

[](#config-file-content)

File with config must return array.

```
// app.php
