Giter VIP home page Giter VIP logo

config's Introduction

Config Version 2.0

What is it?

Config is a class for use in PHP based projects, this class allows you to easily use JSON to store information or configurations that can be read and written to with a small amount of code.

Functions

Function Parameters Description Returns
get_doc N/A Get the decoded contents of a JSON file Array of file contents
new_doc N/A Generate a new empty JSON file with the provided name True on success
set_value Key, Value, Readable (Uncompressed if true) Write a value to an existing JSON file True on success
backup Filename Backup the current contents of a JSON file True on success

Usage

The class can easily be implemented using the following code

<?php

require 'config_v2.php';

// Create a new config object providing the path to the file or where you wish to create a Filename
// and the name of the file
$conf = new Config('/', 'general');

// Create new config file
$conf->new_doc();

// Write to the config file, the depth (This is where the key:value pair are
// located eg {"details": {"name":"Dylan"}} would be a depth of 2), key and value must be provided
$conf->set_value('details', array('name'=>'dylan'), true);

// Read from the config file, this will give you an array of contents
$conf->get_doc();

// Create backup of the file, this requires the name to give the file containing the backup
// backups will be located in the .backup/ folder created in the provided directory
$conf->backup('bk_21.08.17');

Other information

The folder that will contain or already contains the JSON file you wish to interact with must already exist before you try to interact with it using this class

config's People

Contributors

sorcerergrey avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.