# Key Value Store PHP
kvs-php is a rudimentary key/value store written in PHP.
# Getting the project
You can get a copy of this project by clicking on the
[ZIP](https://git.dlma.com/kvs-php.git/zipball/main)
or [TAR](https://git.dlma.com/kvs-php.git/tarball/main) buttons
near the top right of the GitList web page.
If you're me, and you want to contribute to the repo, then you can clone it like so:
git clone ssh://USERNAME@dlma.com/~/git/kvs-php.git
# Building it
1. Ensure your server's version of PHP supports PDO and SQLite.
2. Move config.php.sample to config.php, and replace `replaceme` with a passcode you choose.
3. Optional: Use secure HTTP. I recommend getting a free SSL certificate from [Let's Encrypt](https://letsencrypt.org/).
# Using it
Here is [a live instance that serves an index page](https://kvs-php.dlma.com/). You can send a key to get a value like so:
https://kvs-php.dlma.com/?k=1Gxxxxxxxxxx
Special use case, here's how to get the value for the most-recently updated key of a list of keys. The list could contain any number of keys, but only one value will be returned.
https://kvs-php.dlma.com/?k=1Gxxxxxxxxxx,1Gxxxxxxxxxz
Here's the recipe for a cURL command to store a new value for a key:
curl --data "key=value&auth={authorization}" https://{url}
Here's [the source code for a Roku channel client of such a service](https://git.dlma.com/roku_ip_tagger.git/).
# Trouble shooting
If you get the error "Exception : SQLSTATE\[HY000] \[14] unable to open database file", then [PHP's owner probably doesn't match the directory's owner](https://stackoverflow.com/questions/5165183/apache-permissions-php-file-create-mkdir-fail). You may be able to fix it by noting PHP's owner from phpinfo(), and then invoke "sudo chown phpowner:phpowner (appropriate\_target)".
# Is it any good?
[Yes](https://news.ycombinator.com/item?id=3067434).
# Licence
This software uses the [MIT license](https://git.dlma.com/kvs-php.git/blob/main/LICENSE.txt).