使用phpize构建tokenizer扩展
cd php-8.2.0/ext/tokenizer/
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make
报错
make: *** No rule to make target '/usr/src/php/ext/tokenizer/Zend/zend_language_parser.y', needed by '/usr/src/php/ext/tokenizer/Zend/zend_language_parser.c'. Stop.
修改php-8.2.0/ext/tokenizer/Makefile.frag
vim php-8.2.0/ext/tokenizer/Makefile.frag
修改内容如下
$(top_srcdir)/ext/tokenizer/tokenizer_data.c: $(top_srcdir)/Zend/zend_language_parser.h
@if test ! -z "$(PHP)"; then \
$(PHP) $(srcdir)/tokenizer_data_gen.php; \
fi;
#$(builddir)/tokenizer.lo: $(top_srcdir)/Zend/zend_language_parser.c $(top_srcdir)/Zend/zend_language_scanner.c
重新构建
cd php-8.2.0/ext/tokenizer/
./configure
make distclean
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make
make install
打开php.ini的tokenizer扩展
extension=tokenizer
检查是否安装成功
<?php
if (extension_loaded('tokenizer')) {
echo "Tokenizer扩展已成功加载!";
} else {
echo "无法加载Tokenizer扩展。";
}
?>