PHP Classes
elePHPant
Icontem

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    
Last Updated Ratings Unique User Downloads Download Rankings
2018-02-06 (10 days ago) RSS 2.0 feedStarStarStarStar 73%Total: 204 This week: 9All time: 8,029 This week: 76Up
Version License PHP version Categories
flatconfig 1.0.2MIT/X Consortium ...5.3PHP 5, Files and Folders, Configuration
Collaborate with this project Author

FlatConfig - github.com

Description

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.

  Performance   Level  
Name: Miraz Mac <contact>
Classes: 5 packages by
Country: Bangladesh Bangladesh
Age: 23
All time rank: 306944 in Bangladesh Bangladesh
Week rank: 67 Up2 in Bangladesh Bangladesh Up
Innovation award
Innovation award
Nominee: 2x

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  
 100%
Total:204
This week:9
All time:8,029
This week:76Up
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:185
 
Well done :)
1 year ago (Johnny Mast)
60%StarStarStarStar