Skip to content

Commit

Permalink
Comments and readme updated
Browse files Browse the repository at this point in the history
  • Loading branch information
fire015 committed Mar 11, 2014
1 parent 55f5be1 commit ec20613
Show file tree
Hide file tree
Showing 6 changed files with 100 additions and 64 deletions.
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Change Log
==========

### 11/03/2014 - 1.4
* Now using Composer

### 16/07/2013 - 1.3
* Changed the load method to static so that multiple instances can be loaded without conflict (use Flintstone::load now instead of $db->load)
* Exception thrown is now FlintstoneException

### 23/01/2013 - 1.2
* Removed the multibyte unserialize method as it seems to work without

### 22/06/2012 - 1.1
* Added new method getKeys() to return an array of keys in the database (thanks to sinky)

### 17/06/2011 - 1.0
* Initial release
130 changes: 67 additions & 63 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,33 @@ Features include:

For full documentation please visit http://www.xeweb.net/flintstone/

Requirements
-------------
### Installation

* PHP 5
* Read/write file permissions
The easiest way to install Flintstone is via [composer](http://getcomposer.org/). Create the following `composer.json` file and run the `php composer.phar install` command to install it.

Data types
----------
```json
{
"require": {
"fire015/flintstone": "*"
}
}
```

```php
<?php
require 'vendor/autoload.php';

use Flintstone\Flintstone;

$users = Flintstone::load('users', $options);
```

### Requirements

- Any flavour of PHP 5.3+ should do
- [optional] PHPUnit to execute the test suite

### Data types

Flintstone can store the following data types:

Expand All @@ -29,65 +48,50 @@ Flintstone can store the following data types:
* Floats
* Arrays

Usage examples
---------------

try {

// Set options
$options = array('dir' => '/path/to/database/dir/');
// Load the databases
$users = Flintstone::load('users', $options);
$settings = Flintstone::load('settings', $options);
// Set keys
$users->set('bob', array('email' => 'bob@site.com', 'password' => '123456'));
$users->set('joe', array('email' => 'joe@site.com', 'password' => 'test'));
$settings->set('site_offline', 1);
$settings->set('site_back', '3 days');
// Retrieve keys
$user = $users->get('bob');
echo 'Bob, your email is ' . $user['email'];
$offline = $settings->get('site_offline');
if ($offline == 1) {
echo 'Sorry, the website is offline<br />';
echo 'We will be back in ' . $settings->get('site_back');
}
// Retrieve all key names
$keys = $users->getKeys(); // returns array('bob', 'joe', ...)
foreach ($keys as $username) {
$user = $users->get($username);
echo $username.', your email is ' . $user['email'];
echo $username.', your password is ' . $user['password'];
}
// Delete a key
$users->delete('joe');
// Flush the database
$users->flush();
}
catch (FlintstoneException $e) {
echo 'An error occured: ' . $e->getMessage();
}

### Usage examples

## Changelog
```php
try {

### 16/07/2013 - 1.3
* Changed the load method to static so that multiple instances can be loaded without conflict (use Flintstone::load now instead of $db->load)
* Exception thrown is now FlintstoneException
// Set options
$options = array('dir' => '/path/to/database/dir/');

### 23/01/2013 - 1.2
* Removed the multibyte unserialize method as it seems to work without
// Load the databases
$users = Flintstone::load('users', $options);
$settings = Flintstone::load('settings', $options);

// Set keys
$users->set('bob', array('email' => 'bob@site.com', 'password' => '123456'));
$users->set('joe', array('email' => 'joe@site.com', 'password' => 'test'));
$settings->set('site_offline', 1);
$settings->set('site_back', '3 days');

// Retrieve keys
$user = $users->get('bob');
echo 'Bob, your email is ' . $user['email'];

$offline = $settings->get('site_offline');
if ($offline == 1) {
echo 'Sorry, the website is offline<br />';
echo 'We will be back in ' . $settings->get('site_back');
}

// Retrieve all key names
$keys = $users->getKeys(); // returns array('bob', 'joe', ...)

foreach ($keys as $username) {
$user = $users->get($username);
echo $username.', your email is ' . $user['email'];
echo $username.', your password is ' . $user['password'];
}

### 22/06/2012 - 1.1
* Added new method getKeys() to return an array of keys in the database (thanks to sinky)
// Delete a key
$users->delete('joe');

### 17/06/2011 - 1.0
* Initial release
// Flush the database
$users->flush();
}
catch (FlintstoneException $e) {
echo 'An error occured: ' . $e->getMessage();
}
```
4 changes: 4 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"name": "fire015/flintstone",
"type": "library",
"description": "A key/value database store using flat files for PHP",
"keywords": ["flintstone", "database", "cache", "files", "memory"],
"homepage": "http://www.xeweb.net/flintstone/",
Expand All @@ -13,6 +14,9 @@
"require": {
"php": ">=5.3.0"
},
"require-dev": {
"phpunit/phpunit": "3.7.*"
},
"autoload": {
"psr-0": {
"Flintstone": "src/"
Expand Down
2 changes: 1 addition & 1 deletion src/Flintstone/Flintstone.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class Flintstone {
* @access public
* @var string
*/
const VERSION = '2.0.0';
const VERSION = '1.4';

/**
* Static instance
Expand Down
5 changes: 5 additions & 0 deletions src/Flintstone/FlintstoneDB.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
<?php

/**
* Flintstone - A key/value database store using flat files for PHP
* Copyright (c) 2014 Jason M
*/

namespace Flintstone;

class FlintstoneDB {
Expand Down
5 changes: 5 additions & 0 deletions src/Flintstone/FlintstoneException.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
<?php

/**
* Flintstone - A key/value database store using flat files for PHP
* Copyright (c) 2014 Jason M
*/

namespace Flintstone;

class FlintstoneException extends \Exception {
Expand Down

0 comments on commit ec20613

Please sign in to comment.