https://github.com/pandaplatform/config
[READ-ONLY] Subtree split of the Panda Config Package
https://github.com/pandaplatform/config
Last synced: about 1 year ago
JSON representation
[READ-ONLY] Subtree split of the Panda Config Package
- Host: GitHub
- URL: https://github.com/pandaplatform/config
- Owner: PandaPlatform
- License: mit
- Created: 2017-06-22T07:29:35.000Z (almost 9 years ago)
- Default Branch: 2.1
- Last Pushed: 2024-11-25T16:04:23.000Z (over 1 year ago)
- Last Synced: 2025-04-14T12:05:03.806Z (about 1 year ago)
- Language: PHP
- Homepage: https://github.com/PandaPlatform/framework
- Size: 13.7 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Configuration
> **[READ-ONLY]** Subtree split of the Panda Config Package
- [Introduction](#introduction)
- [Shared Configuration](#shared-configuration)
- [Configuration parsers](#configuration-parsers)
- [Accessing Configuration Values](#accessing-configuration-values)
## Introduction
All of the configuration files for the Panda framework are stored in the `config` directory. The main configuration file is named `config-default` followed by the extension according to the configuration type.
The main configuration file should include all the necessary config values for all the different services or features of your application.
## Shared Configuration
The configuration values are being loaded in a common/shared configuration that is accessible during runtime at any time without the access to the configuration object.
Shared configuration is a sub-set of the shared registry and it can keep its values during runtime across different objects.
## Configuration parsers
The default configuration parser for the configuration files is the `\Panda\Config\Parsers\JsonParser` which support json files.
The job of the parsers (from the `config` package) is to parse the configuration files and return an array of their values.
## Accessing Configuration Values
You may easily access your configuration values using the `SharedConfiguration` object.
The configuration values may be accessed using "dot" syntax, which is being translated in encapsulated groups of values.
A default value may also be specified and will be returned if the configuration option does not exist:
```php
use \Panda\Config\SharedConfiguration;
$config = new SharedConfiguration();
$value = $config->get('routes.base_dir', $default = null);
```
You can also set configuration values at runtime:
```php
use \Panda\Config\SharedConfiguration;
$config = new SharedConfiguration();
$config->set('logger.enabled', false);
```