The Google LevelDB is a C/C++ key-value storage library, this means you can only write C/C++ code to use LevelDB. Unlike other key-value storage solution and MySQL, LevelDB doesn’t have a network server.
If you wan your PHP code to work with LevelDB, you can either wrap LevelDB as a PHP module, or wrap LevelDB as a network server. Writing a PHP LevelDB module is not a good idea most of the time, because we always want to connect to one LevelDB from several machines across network.
This is why I create SSDB – a LevelDB server with zset data type support. SSDB has a very simple network protocol, that can be implemented with many programming language, such as C, C++, PHP, Python, Cpy…
Here is a example of PHP operates with SSDB(LevelDB):
<?php require_once('SSDB.php'); $ssdb = new SimpleSSDB('127.0.0.1', 8888); $resp = $ssdb->set('key', '123'); $resp = $ssdb->get('key'); echo $resp; // output: 123
Download SSDB from: https://github.com/ideawu/ssdb