PHPackages                             smh/flintstone - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. smh/flintstone

ActivePackage[Database &amp; ORM](/categories/database)

smh/flintstone
==============

laravel package key/value database store using flat files.we don't need redis on shared server by this.

13PHP

Since Mar 25Pushed 7y agoCompare

[ Source](https://github.com/SeyedMohsenHosseini/flintstone)[ Packagist](https://packagist.org/packages/smh/flintstone)[ RSS](/packages/smh-flintstone/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependenciesVersions (1)Used By (0)

Flientstone Package for Laravel
===============================

[](#flientstone-package-for-laravel)

A key/value database store using flat files for laravel.

### Requirements

[](#requirements)

- PHP 7.0+
- laravel 5.0+

Features include:

- Memory efficient
- File locking
- Caching
- Gzip compression
- Easy to use

For full documentation please visit original project on

### Data types

[](#data-types)

Flintstone can store any data type that can be formatted into a string. By default this uses `serialize()`. See [Changing the formatter](#changing-the-formatter) for more details.

### Options

[](#options)

NameTypeDefault ValueDescriptiondirstringthe current working directoryThe directory where the database files are stored (this should be somewhere that is not web accessible) e.g. /path/to/database/extstring.datThe database file extension to usegzipbooleanfalseUse gzip to compress the databasecacheboolean or objecttrueWhether to cache `get()` results for faster data retrievalformatternull or objectnullThe formatter class used to encode/decode dataswap\_memory\_limitinteger2097152The amount of memory to use before writing to a temporary file### Install to laravel

[](#install-to-laravel)

you can install this package with command :

`composer require smh/flintstone`

then Add the following line to app.php on config folder:

providers:

```
smh\Flintstone\FlintstoneServiceProvider::class,

```

aliases

```
'Flintstone' => \smh\Flintstone\FlintstoneFacade::class,

```

And run command

```
php artisan vendor:publish

```

### Usage examples

[](#usage-examples)

you can set flintstone config on .env or not

for example enter to .env:

```
FlintstoneDatabaseName=flientstoneDB
FlintstoneConfig_dir=/storage/app
FlintstoneConfig_ext=.dat
FlintstoneConfig_gzip=true
FlintstoneConfig_cache=true
```

if you don't set env, flintstone set by default with confif\\flintstone.php also if you need to database formatter set this property in confif\\flintstone.php

for example

```
"formatter"=>new Json_formatter();
```

Then you can use it anywhere from the project by :

```
use smh\Flientstone;

// Load a database
$users = new Flientstone();
```

or

```
// Load a database
$users = new Flentstone('filename','[
        "dir"=>'/storage/app',
        "FlintstoneConfig_ext"=>'.dat',
        "FlintstoneConfig_gzip"=true
        "FlintstoneConfig_cache"=true]');

// Set a key
$users->set('bob', ['email' => 'bob@site.com', 'password' => '123456']);

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

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

// Retrieve all data
$data = $users->getAll(); // returns array('bob' => array('email' => 'bob@site.com', 'password' => '123456'));

// Delete a key
$users->delete('bob');

// Flush the database
$users->flush();
```

### Changing the formatter

[](#changing-the-formatter)

By default Flintstone will encode/decode data using PHP's serialize functions, however you can override this with your own class if you prefer.

Just make sure it implements `Flintstone\Formatter\FormatterInterface` and then you can provide it as the `formatter` option.

If you wish to use JSON as the formatter, Flintstone already ships with this as per the example below:

```
