当前位置: 首页 > news >正文

php 8.2 配置安装php-zbarcode扩展

前言

https://www.cnblogs.com/niuben/p/19274540

由于这篇帖子的 php-zbarcode 扩展,不支持 php8

所以使用 https://github.com/micbox/php-zbarcode 来进行安装

下载代码

git clone https://github.com/micbox/php-zbarcode
cd php-zbarcode

兼容修复

sudo sed -i '92,100s/unsigned int major = 0, minor = 0;/unsigned int major = 0, minor = 0, patch = 0;/' zbarcode.c
sudo sed -i '99s/zbar_version(&major, &minor);/zbar_version(&major, &minor, &patch);/' zbarcode.c
sudo sed -i '100s/"%d.%d"/"%d.%d.%d"/' zbarcode.csudo sed -i '354s/instanceof_function_ex(Z_OBJCE_P(image), php_zbarcode_image_sc_entry, 0)/instanceof_function(Z_OBJCE_P(image), php_zbarcode_image_sc_entry)/' zbarcode.c
sudo sed -i '364s/instanceof_function_ex(Z_OBJCE_P(image), php_imagick_get_class_entry(), 0)/instanceof_function(Z_OBJCE_P(image), php_imagick_get_class_entry())/' zbarcode.csudo sed -i '/#ifdef HAVE_ZBARCODE_GD/,/#endif/d' zbarcode.c

编译代码

我这里用了宝塔

sudo /www/server/php/82/bin/phpize
export PKG_CONFIG_PATH="/usr/lib/x86_64-linux-gnu/ImageMagick-6.9.11/bin-q16hdri/pkgconfig:$PKG_CONFIG_PATH"./configure --with-php-config=/www/server/php/82/bin/php-config --enable-zbarcode-imagick --enable-zbarcode-gd
make clean && make -j$(nproc) && sudo make install

安装成功输出:

/bin/sh /usr/local/src/php-zbarcode/libtool --tag=CC --mode=link cc -shared -I/usr/local/src/php-zbarcode/include -I/usr/local/src/php-zbarcode/main -I/usr/local/src/php-zbarcode -I/www/server/php/82/include/php -I/www/server/php/82/include/php/main -I/www/server/php/82/include/php/TSRM -I/www/server/php/82/include/php/Zend -I/www/server/php/82/include/php/ext -I/www/server/php/82/include/php/ext/date/lib -I/usr/include/x86_64-linux-gnu/ImageMagick-6 -I/usr/include/ImageMagick-6  -DHAVE_CONFIG_H  -g -O2 -D_GNU_SOURCE    -o zbarcode.la -export-dynamic -avoid-version -prefer-pic -module -rpath /usr/local/src/php-zbarcode/modules  zbarcode.lo -lzbar -lMagickWand-6.Q16HDRI -lMagickCore-6.Q16HDRI
cc -shared  .libs/zbarcode.o  -lzbar /usr/lib/x86_64-linux-gnu/libMagickWand-6.Q16HDRI.so /usr/lib/x86_64-linux-gnu/libMagickCore-6.Q16HDRI.so  -Wl,-soname -Wl,zbarcode.so -o .libs/zbarcode.so
creating zbarcode.la
(cd .libs && rm -f zbarcode.la && ln -s ../zbarcode.la zbarcode.la)
/bin/sh /usr/local/src/php-zbarcode/libtool --tag=CC --mode=install cp ./zbarcode.la /usr/local/src/php-zbarcode/modules
cp ./.libs/zbarcode.so /usr/local/src/php-zbarcode/modules/zbarcode.so
cp ./.libs/zbarcode.lai /usr/local/src/php-zbarcode/modules/zbarcode.la
PATH="$PATH:/sbin" ldconfig -n /usr/local/src/php-zbarcode/modules
----------------------------------------------------------------------
Libraries have been installed in:/usr/local/src/php-zbarcode/modulesIf you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:- add LIBDIR to the `LD_LIBRARY_PATH' environment variableduring execution- add LIBDIR to the `LD_RUN_PATH' environment variableduring linking- use the `-Wl,--rpath -Wl,LIBDIR' linker flag- have your system administrator add LIBDIR to `/etc/ld.so.conf'See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------Build complete.
Don't forget to run 'make test'.root@VM-16-4-debian:/usr/local/src/php-zbarcode# sudo make install
Installing shared extensions:     /www/server/php/82/lib/php/extensions/no-debug-non-zts-20220829/

配置启用扩展

# vim 手动添加 
vim /www/server/php/82/etc/php.ini 
vim /www/server/php/82/etc/php-cli.iniextension=/www/server/php/82/lib/php/extensions/no-debug-non-zts-20220829/zbarcode.so

立刻验证

/www/server/php/74/bin/php -m | grep zbarcode

输出 zbarcode 为成功

创建一个页面,搜索zbarcode 是否存在

<?php phpinfo(); ?>
http://www.jsqmd.com/news/53088/

相关文章:

  • 庸者谋事,智者谋局
  • 热血体育竞技 赛场荣耀时刻
  • 2025 年最新推荐液位计厂家排行榜:聚焦投入式 / 磁致伸缩 / 防爆 / 防水 / 浮球液位计优质企业
  • 奥运赛事激情对决 体育竞技热血启航
  • 2025 年传感器厂家最新推荐排行榜:磁致伸缩 / 防爆 / 液位等多类型产品权威测评与实力解析线性 / 矿用 / 直线 / 油缸位移传感器 / 液位传感器公司推荐
  • 【相反数】暴力即可
  • 【JPCS出版 | 前五届均已见刊检索】第六届材料化学与复合材料国际学术会议(MCCM 2025)
  • synchronized(this) 用法详解
  • 项目写交付文档,数据库文档生成
  • 2025年琉璃瓦厂家推荐排行榜:哪家好?哪家靠谱?选哪家?——基于 CNPP 榜单的对比评测
  • Kafka在Spring Boot生态中的浅析与应用 - 教程
  • 2025年11月成都电线电缆厂家最新推荐,高压电缆、中压电缆、低压电缆、铜芯电缆、铝芯电缆、企业综合服务能力与产品特色深度解析
  • 2025 年最新屏蔽泵厂家排行榜:高温 / 自吸 / 化工等多类型屏蔽泵最新推荐,助力企业精准选品立式 / 液下 / 多级 / 维修 / 低温 / 液化气屏蔽泵推荐
  • NeurIPS 2025|让AI读懂第一视角的“内心独白”!浙大等联合突破性实现自我中心视频推理
  • 实验5 MapReduce初级编程实践
  • 2025年燃气低氮热水锅炉加工厂权威推荐榜单:家庭燃气热水锅炉/立式卧式燃气热水锅炉/半吨燃气热水锅炉设备源头厂家精选
  • 08.入门篇-Java程序运行原理
  • rust关键字unsafe
  • 完整教程:TouchDIVER Pro 触觉手套:Weart把火星岩石触感、手术操作感搬进 XR
  • 2025 年液化气泵厂家最新推荐榜,聚焦技术创新与质量保障的优质品牌深度解析无密封/磁力/倒罐/双端面机械密封/屏蔽/增压液化气泵公司推荐
  • 【水印检查】字符串处理和矩阵的存入
  • 高品质牛肉品牌推荐:安心之选,守护家庭餐桌
  • 06.入门篇-AI编程助手
  • 中药品牌十强排名彰显实力,好医生以完整产业链布局未来
  • 2025年11月电线电缆最新推荐厂家,高压电缆、中压电缆、低压电缆、铜芯电缆、铝芯电缆、铝合金电缆多维度综合考量
  • 从零部署网站客服系统:我踩过的域名和服务器坑,帮你省下几千块!
  • U634637 Star way to heaven
  • 【51单片机】【protues仿真】基于51单片机自动浇花强大的系统
  • 2025 年不锈钢水管厂家最新推荐榜,深度剖析品牌技术实力与市场口碑的核心竞争力薄壁/沟槽/卫生级/环压/快装/316/卡压式不锈钢水管/不锈钢水管工程/不锈钢水管管件/不锈钢水管安装公司推荐
  • 产学研融合!2025年中成药品牌排行榜10强好医生集团的创新引擎