fyre/config

A configuration library.

v4.0.1 2024-10-30 11:51 UTC

This package is auto-updated.

Last update: 2024-10-30 11:52:30 UTC


README

FyreConfig is a free, open-source configuration library for PHP.

Table Of Contents

Installation

Using Composer

composer require fyre/config

In PHP:

use Fyre\Config\Config;

Basic Usage

  • $paths is an array containing the paths.
$config = new Config($paths);

Methods

Add Path

Add a config path.

  • $path is the path to add.
  • $prepend is a boolean indicating whether to prepend the file path, and will default to false.
$config->addPath($path, $prepend);

Clear

Clear config data.

$config->clear();

Consume

Retrieve and delete a value from the config using "dot" notation.

  • $key is the key to lookup.
  • $default is the default value to return, and will default to null.
$value = $config->consume($key, $default);

Delete

Delete a value from the config using "dot" notation.

  • $key is the key to remove.
$config->delete($key);

Get

Retrieve a value from the config using "dot" notation.

  • $key is the key to lookup.
  • $default is the default value to return, and will default to null.
$value = $config->get($key, $default);

Get Paths

Get the paths.

$paths = $config->getPaths();

Has

Determine if a value exists in the config.

  • $key is the key to check for.
$has = $config->has($key);

Load

Load a file into the config.

  • $file is a string representing the config file.
$config->load($file);

Remove Path

Remove a path.

  • $path is the path to remove.
$config->removePath($path);

Set

Set a config value using "dot" notation.

  • $key is the key.
  • $value is the value to set.
  • $overwrite is a boolean indicating whether previous values will be overwritten, and will default to true.
$config->set($key, $value, $overwrite);