PHP Classes

Flat Config: Read and write configuration values in JSON files

Recommend this page to a friend!
  Info   View files Example   View files View files (10)   DownloadInstall with Composer Download .zip   Reputation   Support forum (2)   Blog    
Ratings Unique User Downloads Download Rankings
StarStarStarStar 73%Total: 242 All time: 7,977 This week: 203Up
Version License PHP version Categories
flatconfig 1.0.3MIT/X Consortium ...5.3PHP 5, Files and Folders, Configuration
Description Author

This class can read and write configuration values in JSON files.

It can create and read configuration files that store key-values pairs using the JSON format.

The class can also add, update and delete individual configuration values and store them in the JSON configuration file.

Picture of Miraz Mac
  Performance   Level  
Name: Miraz Mac <contact>
Classes: 13 packages by
Country: Bangladesh Bangladesh
Innovation award
Innovation award
Nominee: 5x

Details

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

  Files folder image Files  
File Role Description
Files folder imagesrc (1 file)
Files folder imagetests (2 files)
Accessible without login Plain text file .editorconfig Data Auxiliary data
Accessible without login Plain text file .travis.yml Data Auxiliary data
Accessible without login Plain text file composer.json Data Added Composer
Accessible without login Plain text file example.php Example Example script
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file phpunit.xml Data Auxiliary data
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files  /  src  
File Role Description
  Plain text file FlatConfig.php Class Class source

  Files folder image Files  /  tests  
File Role Description
  Plain text file FlatConfigTest.php Class Class source
  Accessible without login Plain text file non_empty.conf Data Auxiliary data

 Version Control Unique User Downloads Download Rankings  
 0%
Total:242
This week:0
All time:7,977
This week:203Up
User Ratings User Comments (1)
 All time
Utility:93%StarStarStarStarStar
Consistency:93%StarStarStarStarStar
Documentation:87%StarStarStarStarStar
Examples:87%StarStarStarStarStar
Tests:-
Videos:-
Overall:73%StarStarStarStar
Rank:194
 
Well done :)
6 years ago (Johnny Mast)
60%StarStarStarStar