sudo pecl install mongodb problem | unknown type name 'pcre_cache_entry'

Viewed 417

I'm trying to install mongodb exentsion for php 8.0.13 on my MacOS Monterey.

I try sudo pecl install mongodb command: and then get below errror.

/opt/homebrew/Cellar/php@8.0/8.0.13/include/php/ext/spl/spl_iterators.h:151:4: error: unknown type name 'pcre_cache_entry'
                    pcre_cache_entry *pce;
                    ^
1 error generated.
make: *** [php_phongo.lo] Error 1
ERROR: `make' failed

enter image description here

which php: /opt/homebrew/bin/php php -v: PHP 8.0.13 (cli) (built: Nov 28 2021 13:11:14) ( NTS ) Copyright (c) The PHP Group Zend Engine v4.0.13, Copyright (c) Zend Technologies with Zend OPcache v8.0.13, Copyright (c), by Zend Technologies

Can anyone help me for fix this error? Thanks for your attention!

1 Answers

To compile MongoDB using PECL you will have to copy the pcre2.h to php's include directory.

For php@8.0, you can do this, But you will have to do this after every PHP release or if you switch the PHP version.

pcre2_h="$(find "$(brew --cellar pcre2)" -name "pcre2.h")"
cp -f "$pcre2_h" "$(brew --cellar php@8.0)"/*/include/php/ext/pcre

To avoid this I would recommend using shivammathur/extensions brew tap for installing PHP extensions.

Related