PHPackages                             james-draper/sqlite-key-value-store - 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. james-draper/sqlite-key-value-store

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

james-draper/sqlite-key-value-store
===================================

1.1(4y ago)016MITPHPPHP &gt;=8.1.4

Since Apr 2Pushed 4y ago1 watchersCompare

[ Source](https://github.com/JamesDraper/sqlite-key-value-store)[ Packagist](https://packagist.org/packages/james-draper/sqlite-key-value-store)[ RSS](/packages/james-draper-sqlite-key-value-store/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (2)Versions (3)Used By (0)

Sqlite key value store
======================

[](#sqlite-key-value-store)

A package for creating self-contained sqlite key-value stores held in a file.

Usage
-----

[](#usage)

A key-value file is managed via the `\SqliteKeyValueStore\Store` class. To create an instance, pass the absolute path to the key-value file into the constructor. If the file does not exist yet, the constructor will create it.

```
$store = \SqliteKeyValueStore\Store('/path/to/file');

```

There are 2 exceptions that can be thrown by the constructor:

- `\LogicException` if the path is `:memory:`. In memory databases are strictly forbidden.
- `\SqliteKeyValueStore\Exception` if the database connection could not be established.

### Getting a value from the store

[](#getting-a-value-from-the-store)

Values can be retrieved from the store via the `get` method:

```
$value = $store->get('key', 'default value');

```

If the key exists then it is returned. If it does not then the default value (second parameter) is returned instead. The default value is `null` if not specified. `\SqliteKeyValueStore\Exception` if there was an issue retrieving the key.

### Setting a value to the store

[](#setting-a-value-to-the-store)

Values can be added/updated to the store via the `set` method:

```
$value = $store->set('key', 'value');

```

If the key exists then it is updated. If it does not then it is created. `\SqliteKeyValueStore\Exception` if there was an issue setting the key. This method returns the instance for method chaining.

### Removing a value from the store

[](#removing-a-value-from-the-store)

Values can be removed from the store via the `remove` method:

```
$value = $store->remove('key');

```

If the key exists, then it is removed. If it does not exist then nothing happens. `\SqliteKeyValueStore\Exception` if there was an issue deleting the key. This method returns the instance for method chaining.

Searching the store
-------------------

[](#searching-the-store)

There are 3 ways to search the store:

```
// search by keys containing the substring "some_key" where "?" is a wildcard.
$matches = $store->searchKeys('?some_key?', '?');

// search by values containing the substring "some_value" where "?" is a wildcard.
$matches = $store->searchValues('?some_value?', '?');

// search by keys containing the substring "some_key"
// AND by values containing the substring "some_value"
// where "?" is a wildcard.
$matches = $store->search('?some_key?', '?some_value?', '?');

```

The wildcard is an optional argument that defaults to `*`. If it is not exactly 1 character then `\SqliteKeyValueStore\Exception` is thrown. Each method returns a key-value array of pairs that were matched in the store.

Backing up the store
--------------------

[](#backing-up-the-store)

The store can be backed up by calling `backup` and specifying a path to backup the database to. The path must be empty or `\SqliteKeyValueStore\Exception` is thrown. While backing up the database is locked, and all write operations will block until the backup is complete.

```
$store->backup('backup/path');

```

Getting the store size
----------------------

[](#getting-the-store-size)

The size of the store can be determined by calling `getSize` which returns the number of key-value pairs in the store as an integer.

```
$store->getSize();

```

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~15 days

Total

2

Last Release

1483d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/00635c5ec7ef622d99e3f4ac06cb53d3ee3c0486caecf925d301976eb0466c96?d=identicon)[JamesDraper](/maintainers/JamesDraper)

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/james-draper-sqlite-key-value-store/health.svg)

```
[![Health](https://phpackages.com/badges/james-draper-sqlite-key-value-store/health.svg)](https://phpackages.com/packages/james-draper-sqlite-key-value-store)
```

###  Alternatives

[doctrine/orm

Object-Relational-Mapper for PHP

10.2k285.3M6.2k](/packages/doctrine-orm)[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k115.1M102](/packages/jdorn-sql-formatter)[illuminate/database

The Illuminate Database package.

2.8k52.4M9.3k](/packages/illuminate-database)[mongodb/mongodb

MongoDB driver library

1.6k64.0M545](/packages/mongodb-mongodb)[ramsey/uuid-doctrine

Use ramsey/uuid as a Doctrine field type.

90340.3M211](/packages/ramsey-uuid-doctrine)[reliese/laravel

Reliese Components for Laravel Framework code generation.

1.7k3.4M16](/packages/reliese-laravel)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
