Skip to content

Latest commit

 

History

History
49 lines (35 loc) · 918 Bytes

README.md

File metadata and controls

49 lines (35 loc) · 918 Bytes

PHP JSON Handler

Class to open, modify and write json objects in files.

Installation (without composer)

Just include the json.php file.

require 'src/json.php';

Alternatively, namespace and autoload it.

Installation (with composer)

composer require dayjo/php-json-handler

Then use;

use Dayjo\JSON;

Usage

Basic usage includes auto saving, so you just modify the data and it saves!

<?php
$JSON = new JSON('config.json');
$config =& $JSON->data; // You could just do $config->data->name = ...

$config->name = 'dayjo';
$config->last_edited = time();

Options

Auto Save

The optional second parameter to the JSON class allows you to turn off auto save, and make it so you have to run the save function manually for instance;

<?php
$JSON = new JSON('config.json', false);
$config =& $JSON->data;

$config->name = 'dayjo';

$JSON->save();