https://github.com/ofcold/configuration
Configuration item supports laravel extension.
https://github.com/ofcold/configuration
config configuration configuration-management laravel5 laravel55 php
Last synced: 21 days ago
JSON representation
Configuration item supports laravel extension.
- Host: GitHub
- URL: https://github.com/ofcold/configuration
- Owner: ofcold
- License: mit
- Created: 2018-05-31T14:03:09.000Z (almost 8 years ago)
- Default Branch: 1.0
- Last Pushed: 2018-06-01T03:17:00.000Z (almost 8 years ago)
- Last Synced: 2025-01-10T01:37:53.709Z (about 1 year ago)
- Topics: config, configuration, configuration-management, laravel5, laravel55, php
- Language: PHP
- Size: 24.4 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README

Configuration item supports laravel extension.
------------------------
Simplified Chinese Documentation
## Features
- Support component configuration, configuration files can be anywhere.
- Overlay configuration, flexible.
## Environment
php >= 7.1
Laravel >= 5.1
## Installing
```bash
composer require ofcold/configuration
```
## Instructions
We may use such a scenario, in the development of Laravel components, need some configuration, or multiple configuration items. The original Laravel may require you to merge configurations and publish to the root directory.
As the number of components increases, so does the config file.
## Useing
```php
use Ofcold\Configuration\LoaderConfiguration;
use Illuminate\Filesystem\Filesystem;
use Illuminate\Config\Repository;
$loader = new LoaderConfiguration(
$config = new Repository,
new Filesystem
);
$loader->addNamespace('test', __DIR__ . '/tests/config');
print_r(json_encode($config->all()));
// print_r($config->get('test::test.foo') . "\r\n");
$loader->addNamespaceOverrides('test', __DIR__ . '/tests/overrides');
print_r(json_encode($config->all()));
// print_r($config->get('test::test.foo') . "\r\n");
```
#### Results:
```json
{
"test::test":{
"foo":"example"
}
}
{
"test::test":{
"foo":"overrides"
}
}
```
Larvel
```php
use Ofcold\Configuration\LoaderConfiguration;
class Foo
{
/**
* Create an a new Foo instance.
*
* @param LoaderConfiguration $loader
*/
public function __construct(LoaderConfiguration $loader)
{
$loader->addNamespace('test', '/config');
}
}
```
#### OR test file.
```bash
php test
```
### Api
- addNamespace(?string $namespace = null, string $directory) : void
- addNamespaceOverrides($namespace, $directory) : void