Skip to content

Instantly share code, notes, and snippets.

@codewithgun
Last active April 20, 2021 05:34
Show Gist options
  • Save codewithgun/97761f074224a0afdcc2d48359edc5e7 to your computer and use it in GitHub Desktop.
Save codewithgun/97761f074224a0afdcc2d48359edc5e7 to your computer and use it in GitHub Desktop.
LevelDB for laravel

Install LevelDB for Laravel

Install LevelDB

You can install leveldb from repository

sudo apt-get install libleveldb-dev

Install phpize

sudo apt install php-dev

Installation for PHP

git clone https://github.com/reeze/php-leveldb.git
cd php-leveldb
./configure --with-leveldb=~/leveldb.*.*
make
make install

After run make install, your output should be similar as following:

/usr/lib/php/20190902/leveldb.so

Modify php.ini

By default, laravel is using the php.ini of cli version. Meanwhile, apache2 is using its own php.ini.

php --ini
//output: Loaded Configuration File:         /etc/php/7.4/cli/php.ini (cli version)

the php.ini for apache2 can be found at /etc/php/7.4/apache2/php.ini

Open the php.ini with your favorite editor and add the following to it:

extension=leveldb.so

Apache2

If you are using apache2 instead of php artisan serve, remember to reload your apache2 server with the following command

sudo systemctl restart apache2

Example

You can now use leveldb in your project as the following example:

<?php
$db = new LevelDB('./', $options, $readOptions, $writeOptions); 

For more details:

https://github.com/reeze/php-leveldb

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment