Giter Site home page Giter Site logo

varstore's Introduction

VarStore

Robust variable storage for PHP via xml and xpath.

VarStore is a simple lightweight PHP class for basic NoSQL style storage using the getter/setter method.

It works well for rapid prototyping very small web projects. The storage mechansim uses PHPs serialization and XML files.

Getting Started

To get started all you need to do is obtain a copy of the VarStore.php file, include it in a PHP project, and set a directory path for the storage to use.

Once the file has been downloaded it only takes 2 lines of code to set up the system and start using it:

include_once("[path to VarStore.php goes here]");

$storage = new VarStore("[path to where VarStore should store the data goes here]");

$storage is, of course, just an example name. Any name can be used.

It's recommended that the data storage path be somewhere outside the accessible HTTP document root. For instance it could be stored in a directory one level above the htdocs folder. This is simply a security measure to protect the data from prying eyes or accidental exposure.

To store data use:

$storage->setVar("[name to use for identifying the data goes here]", [the data to store goes here]);

VarStore can store any serializable data. Because nearly all variables in PHP are serializable, VarStore can store nearly any PHP variable. The data will be upserted (https://en.wiktionary.org/wiki/upsert). The name does not have to be a string and can be any value.

To retrieve data use:

$storage->getVar("[name to use for identifying the data goes here]", [default value goes here]);

An important concept in VarStore is that a default value must always be provided when retrieving data. This default value will be used in cases where the value is not yet set or cannot be retrieved.

varstore's People

Contributors

whiterobot avatar

Stargazers

 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.