A PHP extension for Facebook ' s ROCKSDB

Source: Internet
Author: User
Tags git clone


A PHP extension for Facebook ' s ROCKSDB
    • commits
    • 2 Branches
    • 0 Releases
    • 2 Contributors
    1. C + + 90.5%
    2. C 8.9%
    3. other 0.6%
C + +c OtherBranch: Master rocksdb-php/


Merge Pull request #1 from Miclen/patch-1 ...


Latest Commit8b6542e285Photonios authored on Feb
Src Update Database.cpp A year ago
Test Revert4c59e30 A year ago
. gitignore Updated Gitignore to ignore Eclipse project files and other junk 2 years ago
Makefile Revert4c59e30 A year ago
Readme.md Revert4c59e30 A year ago
test.sh Revert4c59e30 A year ago
test_valgrind.sh Revert4c59e30 A year ago
readme.md







Rocksdb PHP Extension


Rocksdb is a new embedded database for storing key-value pairs developed by Facebook. This is project hosts a PHP extension for rocksdb. More information on Rocksdb can is found here:



Https://github.com/facebook/rocksdb


Simple Example
<?php    $rocksdb = new RocksDB("my_rocksdb_file");    $result = $rocksdb->Open(true);    if($result)        die("Unable to open rocksdb!");    $rocksdb->Put("my_awesome_key", "my_awesome_value");    $value = $rocksdb->Get("my_awesome_key");    echo $value . "\n";?>


Check for moretest/test.phpexamples.


Platforms


Rocksdb is said-compile on Linux and Mac OS x. So far, I Haven ' t seen anyone getting it-to-build on Windows, and it should work. My Build Environment is:


    • Ubuntu 13.10 x64
    • GCC 4.8.1


All documentation, instructions and guides assume my configuration. If you were able-get it working on another platform, please let me know.


Notes


I use a custom version of Php-cpp, because I added basic exception support. Checkout the fork, until my pull request has been accepted:


git clone https://github.com/Photonios/PHP-CPP
Buildbuilding Rocksdb PHP Extension


Before trying to build the rocksdb PHP extension and make sure you have installed all dependencies listed below. After this, you can simply checkout the code:


git clone https://github.com/Photonios/rocksdb-php.git


Then, run make:


make


The PHP extension, which is a shared/dynamiclly linked library can being found in thebindirectory.


Building PHP


The rocksdb PHP extension is being written against PHP 5.5.3. To is able to build the rocksdb PHP extension, you need to install the following packages:


sudo apt-get install php5-devsudo apt-get install php5-cli
Building Php-cpp


Php-cpp is a C + + library which makes developing PHP extensions from C + + possible. It's also, the easier then using the native PHP C API. Php-cpp can found here:



Https://github.com/EmielBruijntjes/PHP-CPP



To build, clone the repository:


git clone https://github.com/EmielBruijntjes/PHP-CPP.git php-cpp


Go into the ' php-cpp ' directory and run:


make


After that, ' libphpcpp.so ' should is present in the ' src ' directory. To install the library, do one of the following thins:


    • Add the path where you cloned php-cpp to Ld_library_path (export LD_LIBRARY_PATH+=/path/to/php-cpp/src)
    • Create a new file/etc/ld.so.conf.d.confin with the extension, where the path to the Php-cpp src directory are on a single line
    • Copy the file tolibphpcpp.so/usr/lib
Building Rocksdb


To build the Rocksdb PHP Extension, your first need to build Rocksdb. Clone the Rocksdb git repository using:


git clone https://github.com/facebook/rocksdb.git


To being able to build rocksdb, you first need to install all dependencies, this can is done using apt-get:


sudo apt-get install libsnappy-devsudo apt-get install zlib1g-devsudo apt-get install libbz2-devsudo apt-get install libgflags2sudo apt-get install libgflags-dev


Or Run:


sudo apt-get install libsnappy-dev zlib1g-dev libbz2-dev libgflags2 libgflags-dev


After your ' ve install all dependencies, you can simply run:


make cleanmake


To build and run all unit tests:


make check


To install the ROCKSDB library you can do either of these three things:


    • Add the path where you cloned Rocksdb to Ld_library_path (export LD_LIBRARY_PATH+=/path/to/rocksdb)
    • Create a new file/etc/ld.so.conf.d.confin with the extension, where the path to ROCKSDB are on a single line
    • Copy the files and tolibrocksdb.alibmemenv.a/usr/lib


Choose whatever:)


Installation


After your build the Rocksdb PHP extension, you should has a.sofile in thebindirectory. Execute:


php --ini


To find the where your PHP configuration file is located. It should output something liek this:


Loaded Configuration File:         /etc/php5/cli/php.ini


Find the line is starts withextension=, if it's commented out, uncomment it and set the path to your extension, like this:


extension=/iam_awesome/cookies/dance/in/the/rain/rocksdb-php.so


Then, enjoy:D



A PHP extension for Facebook ' s ROCKSDB


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.