In macOS, when using pecl to install some extensions, you will encounter
fatal error: 'pcre2.h' file not founderror, this error is more commonly encountered on macOS;
The root cause is that PHP did not find the pcre2 dependency, so the solution is very simple:
brew install pcre2Then link this pcre2.h file to PHP using a soft link
ln -s /opt/homebrew/Cellar/pcre2/10.40/include/pcre2.h /opt/homebrew/Cellar/php/8.1/include/php/ext/pcre/pcre2.hNote: You need to modify the paths of pcre2 and php
Finally, re-execute the pecl installation command.