mpremus / lmdb-php

PHP interface for LMDB (Lightning Memory-Mapped Database)
GNU General Public License v3.0
30 stars 10 forks source link

Support PHP 7's Extension API #4

Open meinemitternacht opened 7 years ago

meinemitternacht commented 7 years ago

Are there any plans to support PHP 7 with this wrapper? I am interested in integrating LMDB with an embedded device project, but cannot compile this against the PHP 7 headers.

mpremus commented 7 years ago

Hi, unfortunately in close feature I have no plans (read time) to create new version for PHP7.

Regards, Mateo

On Tue, Sep 12, 2017 at 3:58 PM, Claude Bing notifications@github.com wrote:

Are there any plans to support PHP 7 with this wrapper? I am interested in integrating LMDB with an embedded device project, but cannot compile this against the PHP 7 headers.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/mpremus/lmdb-php/issues/4, or mute the thread https://github.com/notifications/unsubscribe-auth/ALMX6PZ8U1aKnn843LBLe8sBgZRi9af5ks5shoehgaJpZM4PUphR .

wkhayrattee commented 6 years ago

hey @mpremus can you give me some hints or guidance as to how to proceed to try to make this lib php7 compatible?

dana321 commented 6 years ago

@7php @meinemitternacht The latest php version 7.2 supports lmdb by compiling the dba extension with --with-lmdb=/path/to/lmdb

dana321 commented 6 years ago

For example, with brew (homebrew/linuxbrew): --- install brew and phpbrew first with php 7.2 ---

brew install lmdb phpbrew ext install dba -- --with-lmdb=/usr/local/opt/lmdb

meinemitternacht commented 6 years ago

@dana321 thank you! I'll give it a look at work tomorrow.

wkhayrattee commented 6 years ago

@dana321 did you even tried running it on Ubuntu 16? Get past all the automated stuffs like "brew", get on the commandline from A to Z. If it works, can you post the exact steps you take, every single details, as it's not working on my end.

Also how can it be working when the Makefile is statically calling php5 ?? gcc -shared -fpic lmdb-php_wrap.c -I/usr/include/php5/Zend/ -I/usr/include/php5/ -I/usr/include/php5/TSRM/ -I/usr/include/php5/main/ -llmdb -o lmdb-php.so

Obviously it has to be something like:

$ gcc -shared `php-config --includes` -fpic -c lmdb-php_wrap.c -llmdb -o /path/to/lmdb-php.so

So my output with errors go something like:

lmdb-php_wrap.c:4478:50: error: macro "ZVAL_STRING" passed 3 arguments, but takes just 2
       ZVAL_STRING(return_value, (char *)result, 1);
                                                  ^
lmdb-php_wrap.c:4478:7: error: 'ZVAL_STRING' undeclared (first use in this function)
       ZVAL_STRING(return_value, (char *)result, 1);
       ^
In file included from /usr/include/php/20151012/Zend/zend.h:33:0,
                 from lmdb-php_wrap.c:706:
lmdb-php_wrap.c: In function '_wrap_destroy_p_f_p_q_const__struct_MDB_val_p_q_const__struct_MDB_val__int':
lmdb-php_wrap.c:4489:9: error: 'rsrc' undeclared (first use in this function)
   efree(rsrc->ptr);
         ^
/usr/include/php/20151012/Zend/zend_alloc.h:163:34: note: in definition of macro 'efree'
 #define efree(ptr)       _efree((ptr) ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC)
                                  ^
lmdb-php_wrap.c: In function '_wrap_destroy_p_f_p_struct_MDB_val_p_void_p_void_p_void__void':
lmdb-php_wrap.c:4493:9: error: 'rsrc' undeclared (first use in this function)
   efree(rsrc->ptr);
         ^
/usr/include/php/20151012/Zend/zend_alloc.h:163:34: note: in definition of macro 'efree'
 #define efree(ptr)       _efree((ptr) ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC)
                                  ^
lmdb-php_wrap.c: In function '_wrap_destroy_p_f_p_struct_MDB_env_p_q_const__char__void':
lmdb-php_wrap.c:4497:9: error: 'rsrc' undeclared (first use in this function)
   efree(rsrc->ptr);
         ^
/usr/include/php/20151012/Zend/zend_alloc.h:163:34: note: in definition of macro 'efree'
 #define efree(ptr)       _efree((ptr) ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC)
                                  ^
lmdb-php_wrap.c: In function '_wrap_destroy_p_MDB_stat':
lmdb-php_wrap.c:4500:3: warning: implicit declaration of function '__wrap_delete_MDB_stat' [-Wimplicit-function-declaration]
   __wrap_delete_MDB_stat(rsrc, SWIGTYPE_p_MDB_stat->name TSRMLS_CC);
   ^
lmdb-php_wrap.c:4500:26: error: 'rsrc' undeclared (first use in this function)
   __wrap_delete_MDB_stat(rsrc, SWIGTYPE_p_MDB_stat->name TSRMLS_CC);
                          ^
In file included from /usr/include/php/20151012/Zend/zend.h:33:0,
                 from lmdb-php_wrap.c:706:
lmdb-php_wrap.c: In function '_wrap_destroy_p_MDB_txn':
lmdb-php_wrap.c:4504:9: error: 'rsrc' undeclared (first use in this function)
   efree(rsrc->ptr);
         ^
/usr/include/php/20151012/Zend/zend_alloc.h:163:34: note: in definition of macro 'efree'
 #define efree(ptr)       _efree((ptr) ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC)
                                  ^
lmdb-php_wrap.c: In function '_wrap_destroy_p_unsigned_int':
lmdb-php_wrap.c:4508:9: error: 'rsrc' undeclared (first use in this function)
   efree(rsrc->ptr);
         ^
/usr/include/php/20151012/Zend/zend_alloc.h:163:34: note: in definition of macro 'efree'
 #define efree(ptr)       _efree((ptr) ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC)
                                  ^
lmdb-php_wrap.c: In function '_wrap_destroy_p_MDB_val':
lmdb-php_wrap.c:4511:3: warning: implicit declaration of function '__wrap_delete_MDB_val' [-Wimplicit-function-declaration]
   __wrap_delete_MDB_val(rsrc, SWIGTYPE_p_MDB_val->name TSRMLS_CC);
   ^
lmdb-php_wrap.c:4511:25: error: 'rsrc' undeclared (first use in this function)
   __wrap_delete_MDB_val(rsrc, SWIGTYPE_p_MDB_val->name TSRMLS_CC);
                         ^
In file included from /usr/include/php/20151012/Zend/zend.h:33:0,
                 from lmdb-php_wrap.c:706:
lmdb-php_wrap.c: In function '_wrap_destroy_p_mode_t':
lmdb-php_wrap.c:4515:9: error: 'rsrc' undeclared (first use in this function)
   efree(rsrc->ptr);
         ^
/usr/include/php/20151012/Zend/zend_alloc.h:163:34: note: in definition of macro 'efree'
 #define efree(ptr)       _efree((ptr) ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC)
                                  ^
lmdb-php_wrap.c: In function '_wrap_destroy_p_void':
lmdb-php_wrap.c:4519:9: error: 'rsrc' undeclared (first use in this function)
   efree(rsrc->ptr);
         ^
/usr/include/php/20151012/Zend/zend_alloc.h:163:34: note: in definition of macro 'efree'
 #define efree(ptr)       _efree((ptr) ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC)
                                  ^
lmdb-php_wrap.c: In function '_wrap_destroy_p_p_void':
lmdb-php_wrap.c:4523:9: error: 'rsrc' undeclared (first use in this function)
   efree(rsrc->ptr);
         ^
/usr/include/php/20151012/Zend/zend_alloc.h:163:34: note: in definition of macro 'efree'
 #define efree(ptr)       _efree((ptr) ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC)
                                  ^
lmdb-php_wrap.c: In function '_wrap_destroy_p_MDB_env':
lmdb-php_wrap.c:4527:9: error: 'rsrc' undeclared (first use in this function)
   efree(rsrc->ptr);
         ^
/usr/include/php/20151012/Zend/zend_alloc.h:163:34: note: in definition of macro 'efree'
 #define efree(ptr)       _efree((ptr) ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC)
                                  ^
lmdb-php_wrap.c: In function '_wrap_destroy_p_char':
lmdb-php_wrap.c:4531:9: error: 'rsrc' undeclared (first use in this function)
   efree(rsrc->ptr);
         ^
/usr/include/php/20151012/Zend/zend_alloc.h:163:34: note: in definition of macro 'efree'
 #define efree(ptr)       _efree((ptr) ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC)
                                  ^
lmdb-php_wrap.c: In function '_wrap_destroy_p_MDB_cursor':
lmdb-php_wrap.c:4535:9: error: 'rsrc' undeclared (first use in this function)
   efree(rsrc->ptr);
         ^
/usr/include/php/20151012/Zend/zend_alloc.h:163:34: note: in definition of macro 'efree'
 #define efree(ptr)       _efree((ptr) ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC)
                                  ^
lmdb-php_wrap.c: In function '_wrap_destroy_p_MDB_cursor_op':
lmdb-php_wrap.c:4539:9: error: 'rsrc' undeclared (first use in this function)
   efree(rsrc->ptr);
         ^
/usr/include/php/20151012/Zend/zend_alloc.h:163:34: note: in definition of macro 'efree'
 #define efree(ptr)       _efree((ptr) ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC)
                                  ^
lmdb-php_wrap.c: In function '_wrap_destroy_p_MDB_envinfo':
lmdb-php_wrap.c:4542:3: warning: implicit declaration of function '__wrap_delete_MDB_envinfo' [-Wimplicit-function-declaration]
   __wrap_delete_MDB_envinfo(rsrc, SWIGTYPE_p_MDB_envinfo->name TSRMLS_CC);
   ^
lmdb-php_wrap.c:4542:29: error: 'rsrc' undeclared (first use in this function)
   __wrap_delete_MDB_envinfo(rsrc, SWIGTYPE_p_MDB_envinfo->name TSRMLS_CC);
                             ^
In file included from /usr/include/php/20151012/Zend/zend.h:33:0,
                 from lmdb-php_wrap.c:706:
lmdb-php_wrap.c: In function '_wrap_destroy_p_f_p_q_const__char_p_void__int':
lmdb-php_wrap.c:4546:9: error: 'rsrc' undeclared (first use in this function)
   efree(rsrc->ptr);
         ^
/usr/include/php/20151012/Zend/zend_alloc.h:163:34: note: in definition of macro 'efree'
 #define efree(ptr)       _efree((ptr) ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC)
                                  ^
lmdb-php_wrap.c: In function '_wrap_destroy_int':
lmdb-php_wrap.c:4550:9: error: 'rsrc' undeclared (first use in this function)
   efree(rsrc->ptr);
         ^
/usr/include/php/20151012/Zend/zend_alloc.h:163:34: note: in definition of macro 'efree'
 #define efree(ptr)       _efree((ptr) ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC)
                                  ^
lmdb-php_wrap.c: In function '_wrap_destroy_p_int':
lmdb-php_wrap.c:4554:9: error: 'rsrc' undeclared (first use in this function)
   efree(rsrc->ptr);
         ^
/usr/include/php/20151012/Zend/zend_alloc.h:163:34: note: in definition of macro 'efree'
 #define efree(ptr)       _efree((ptr) ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC)

/c @meinemitternacht

dana321 commented 6 years ago

@7php Its clear you have no idea what you're doing or what you're talking about - thats ok.

But don't make demands of me, i provided the solution and you're still trying to compile the old php module against the php5 header files. I am under no obligation to help you whatsoever!

Theres a reason why people use and learn linuxbrew and phpbrew, its because you can compile the latest and greatest software without the hastle. Take the hint.

meinemitternacht commented 6 years ago

@7php http://php.net/manual/en/migration72.other-changes.php

The DBA extension natively supports LMDB now, no need for a wrapper.

wkhayrattee commented 6 years ago

@meinemitternacht that was very helpful and it's a great news as I really wanted to use LMDB on a project close to my heart. Thank you sooo much for this info, precious!

cheers

saippuakauppias commented 5 years ago

phpbrew is bad tool (valet not worked with this).

Method for configure and build from sources PHP7 in homebrew: https://gist.github.com/saippuakauppias/fac2a33dfe420adb4a6cf19c257eef46

mpremus commented 5 years ago

I agree. I dont support this plugin for more then 4 years. If you have some code that can improve this please Create a fork and I will merge commit

On Wed, 30 Oct 2019, 22:19 Denis Veselov, notifications@github.com wrote:

phpbrew is bad tool (valet not worked with this).

Method for configure and build from sources PHP7 in homebrew: https://gist.github.com/saippuakauppias/fac2a33dfe420adb4a6cf19c257eef46

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/mpremus/lmdb-php/issues/4?email_source=notifications&email_token=ACZRP2ARZJPPHJVKDBVWSUTQRH25XA5CNFSM4D2STBI2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOECVZTBQ#issuecomment-548116870, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACZRP2DY65VCZ7SCHCQ5SMTQRH25XANCNFSM4D2STBIQ .

meinemitternacht commented 5 years ago

@saippuakauppias is there a reason you would not want to use the DBA extension that is bundled with PHP?

saippuakauppias commented 5 years ago

Because by default php builts without lmdb support (see docs). DBA extension enabled by default, but without lmdb (need reconfigure php before compiling).

wkhayrattee commented 2 years ago

Wow, I cannot believe it's already Jan 2022, so many years later I got back to this :) Hope everyone in here is safe and doing well.

@dana321 I read my comments above and I am not proud of what I wrote up there. That year was one of my worse period in rl, and I clearly see I also completely misunderstood your reply as well at that time.

I'm sorry for my tone and way of speaking there - not the proper me. irrespective of my situation, I should have done much better in replying. Please accept my sincere apology.


@saippuakauppias I actually came here to get in touch with you since I could not find a point of contact with you.

I am hitting MDB_MAP_FULL with LMDB using php_dba and I saw your gist here aimed at MAC.

I also found someone's interaction on the php mail list here. The php-src test as well.

The limit of 1MB seems still in place and I keep hitting the issue despite passing the 4th param as 'map_size=1048576000' since as per the mail list that 4th param is passed as a string to the underlying driver.

Have you been able to find any solution for Ubuntu servers or your case was on Mac only? Because of this issue, I'll probably drop usage for LMDB, which is sad due the power it has.

saippuakauppias commented 2 years ago

On Ubuntu, I just build LMDB and PHP myself and bypass this restriction (I've been using it in production for over a year):

set -euo pipefail

# install lmdb
apt -y install make gcc wget
cd ~
    # clone
LMDB_VERSION="0.9.24"
wget https://github.com/LMDB/lmdb/archive/LMDB_${LMDB_VERSION}.tar.gz

tar -zxvf LMDB_${LMDB_VERSION}.tar.gz

cd ~/lmdb-LMDB_${LMDB_VERSION}/libraries/liblmdb/
    # patch 1
# get memory pagesize: `getconf PAGESIZE`
# 4194304000 Bytes = 4GB
sed -e "s/DEFAULT_MAPSIZE\s1048576/DEFAULT_MAPSIZE 4194304000/g" ~/lmdb-LMDB_${LMDB_VERSION}/libraries/liblmdb/mdb.c -i
LMDB_MAPSIZE_CHECK=`cat ~/lmdb-LMDB_${LMDB_VERSION}/libraries/liblmdb/mdb.c | grep '4194304000' | wc -l`
echo "LMDB_MAPSIZE_CHECK: ${LMDB_MAPSIZE_CHECK}"

    # patch 2
sed -e "s/DEFAULT_READERS\s126/DEFAULT_READERS 1024/g" ~/lmdb-LMDB_${LMDB_VERSION}/libraries/liblmdb/mdb.c -i
LMDB_READERS_CHECK=`cat ~/lmdb-LMDB_${LMDB_VERSION}/libraries/liblmdb/mdb.c | grep 'DEFAULT_READERS 1024' | wc -l`
echo "LMDB_READERS_CHECK: ${LMDB_READERS_CHECK}"

    # install
make
make test
make install prefix=/opt/lmdb # directory path: https://ru.wikipedia.org/wiki/FHS

# install PHP
# like: https://gist.github.com/saippuakauppias/d3e2cdd1c654313efefef3b8b66a5802
# with :
PHP_CONFIGURE_ARGS="--prefix=/usr/local/php7 \
# ...
  --enable-dba \
  --with-lmdb=/opt/lmdb \
"