Git Product home page Git Product logo

packer-php's Introduction

Packer-PHP

Simple Key-Value Storage for PHP.

Packer aims to be a zero-config, zero-install and works as PHP works library that developers can quickly pull into their project for use immediately for small and medium scaling usage.

Build Status

Installation via Composer

To use Packer in your project, add a dependency to mauris/packer in your project's composer.json file. The following is a minimal sample configuration to use Packer in your project.

{
    "require": {
        "mauris/packer": "1.0"
    }
}

After which run the command:

php composer.phar install

Learn more about Composer.

Usage

Once you have installed Packer as your project's dependencies using Composer, you can use the Packer class directly in your code.

To work with a Packer file, you create an instance of Packer like this:

$packer = new Packer\Packer('config.pack');

Writing / Overwriting

To write a key and value entry to the Packer file, simply use the write($key, $value) method like this:

$packer->write('autorun', false);

Reading

To fetch a value from a Packer file, use the read($key) method.

$autorun = $packer->read('autorun');

Deleting

To delete a value from the Packer file:

$packer->delete('autorun');
// $packer->exist('autorun') === false

Fetch all keys

To iterate through the Packer file, you can fetch the keys using the keys() method:

echo '<ul>';
foreach($packer->keys() as $key){
    echo '<li>' . $packer->read($key) . '</li>';
}
echo '</ul>';

Clearing

To remove all entries from the Packer file:

$packer->clear();

License

Packer is released open source under the New BSD 3-Clause License.

packer-php's People

Contributors

mauris avatar jorgesumle avatar

Watchers

James Cloos avatar  avatar  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.