PHP Classes
elePHPant
Icontem

File: README.md

Recommend this page to a friend!
  Classes of Miraz Mac  >  Flat Config  >  README.md  >  Download  
File: README.md
Role: Documentation
Content type: text/markdown
Description: Documentation
Class: Flat Config
Read and write configuration values in JSON files
Author: By
Last change: Added Composer Installation Command
Date: 1 year ago
Size: 1,476 bytes
 

Contents

Class file image Download

FlatConfig

FlatConfig is a lightweight flat file configuration management PHP class. It uses JSON and file storage to store configuration data. The code is well commented so here I just provided some basic usage example. For brief description please explore the code <3

*NOTE: Don't forget to protect your configurtion file from direct access!*

Install via composer

composer require mirazmac/flatconfig

How to use this thing?

To use FlatConfig, we need to create an instance first with the path to the configuration file. File will be created automaticly if doesn't exist.

$configFile = __DIR__ .'/config.json';
use mirazmac\FlatConfig;
// Create a new instance
$config = New FlatConfig($configFile);

Add some data

$config->add('name', 'Miraz');
$config->add('url', 'https://mirazmac.info');
$config->add('comment', 'Hmm! Looking great watson!');

Update data

$config->update('name', 'Miraz Mac');

Delete data

$config->delete('url');

Retrieve the whole config array

var_dump($config->getAll());

Get a single value by its key

$name = $config->get('name');
echo $name;

Thats all folks!

forthebadge forthebadge