首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式碼之家 >> 編程語言 >  >> 網頁程式設計 >> PHP 程式設計 >> PHP 相關知識

PHP Windows 擴展 DLL 官方下載匯總:PECL 釋出版本對應表與安裝避坑指南

     編輯:PHP 相關知識

Windows 環境下 PHP 擴展安裝一直是開發者痛點:版本號(VC 編譯器、TS/NTS、位數)、依賴庫、加載順序稍有不匹配就報 Unable to load dynamic library。本文彙總官方下載站點、版本對應規則、常用擴展清單與安裝標準流程,助你一次成功。

官方下載權威站點

PHP 版本站點說明
5.2 / 5.3https://downloads.php.net/pierre/Pierre Joye 早期構建,含 php_oci8.dll、php_memcache.dll 等經典擴展
5.3 / 5.4 / 5.5 / 5.6 / 7.0 / 7.1 / 7.2 / 7.3 / 7.4 / 8.0 / 8.1 / 8.2 / 8.3https://windows.php.net/downloads/pecl/releases/PECL 官方釋出版本庫,**首選站點**,每個擴展有獨立目錄與版本歷史
所有版本https://pecl.php.net/package/擴展元數據頁,含 changelog、依賴、DLL 下載鏈接

版本號解碼:必須四項匹配

下載頁面文件名格式:php_{ext}-{version}-{php_version}-{vc}-{ts|nts}-{x86|x64}.zip

字段含義如何確認
{php_version}PHP 大版本php -v → PHP 8.2.12 → 下載 8.2 目錄
{vc}Visual C++ 編譯器版本php -i | findstr "Compiler" → VC15/VS16 等
ts / ntsThread Safe / Non-Thread Safephp -i | findstr "Thread Safety" → enabled 選 ts,否則 nts
x86 / x6432 位 / 64 位php -i | findstr "Architecture" → x64 選 x64

示例:PHP 8.2.12 NTS x64 VC15 → 下載 php_redis-5.3.7-8.2-nts-vs16-x64.zip。

常用擴展清單(PECL 釋出版本)

以下擴展在 https://windows.php.net/downloads/pecl/releases/{ext}/ 目錄下均有穩定版:

擴展用途依賴庫(需放入 PATH)
redisRedis 客戶端無
memcachedMemcached 客戶端libmemcached.dll, libsasl.dll
mongodbMongoDB 官方驅動無
amqpRabbitMQ 客戶端rabbitmq.4.dll
swoole高性能協程框架無(含 OpenSSL)
openswooleSwoole 分支無
xdebug調試/覆蓋率無
imagickImageMagick 封裝ImageMagick 7.x DLLs
gd圖形處理(內建)無
pdo_sqlsrv / sqlsrvSQL Server 驅動ODBC Driver 17/18
pdo_oci / oci8Oracle 驅動Instant Client SDK
ssh2SSH2 協議libssh2.dll
yamlYAML 解析libyaml.dll
zipZIP 壓縮(內建)無
apcu用戶緩存無
opcacheOpcode 緩存(內建)無
grpcgRPC 客戶端grpc.dll
protobufProtocol Buffers無

標準安裝流程(以 Redis 為例)

  1. 確認環境:php -v、php -i | findstr "Thread Safety\|Compiler\|Architecture"
  2. 下載對應 ZIP:進入 https://windows.php.net/downloads/pecl/releases/redis/,選擇版本目錄(如 5.3.7),下載匹配的 zip。
  3. 解壓 DLL:將 php_redis.dll 放入 PHP ext 目錄(C:\php\ext)。
  4. 依賴庫入 PATH:若擴展需外部 DLL(如 libmemcached.dll),放入 PHP 根目錄或系統 PATH 目錄。
  5. 修改 php.ini:extension=redis(無需 .dll 後綴,PHP 7.2+ 自動識別)。
  6. 重啟服務:systemctl restart php-fpm / IIS 回收應用程序池 / Apache 重啟。
  7. 驗證:php -m | findstr redis 或 php -r "var_dump(extension_loaded('redis'));"

常見報錯與修復

錯誤信息原因修復
Unable to load dynamic library 'redis'DLL 路徑錯、文件名錯、位數不匹配確認 extension_dir、文件名、x86/x64
The specified module could not be found缺少依賴 DLL(如 libmemcached.dll)將依賴 DLL 放入 PHP 根目錄或 PATH
Module compiled with module API=20210902, PHP compiled with module API=20220829PHP 小版本不匹配(如 8.1 載入 8.2 的 DLL)嚴格匹配 php_version 字段
Thread Safety mismatchTS 載入 NTS 或反向重新下載匹配 ts/nts 版本
VC runtime missing缺少 Visual C++ Redistributable安裝對應 VC 運行庫(VC15→VS2015-2022 Redist)

進階:Composer 平台包模擬擴展(無 DLL 環境)

若無法安裝 DLL(如共享主機、CI 環境),可用純 PHP 實現替代:

composer require symfony/polyfill-mbstring  # 模擬 mbstring
composer require ramsey/uuid                # 替代 uuid 擴展
composer require firebase/php-jwt           # 替代 openssl 簽名功能

雖性能不如 C 擴展,但解決「無法安裝擴展」的部署受限問題。

總結

Windows PHP 擴展安裝核心口訣:版本號四項全匹配、依賴庫進 PATH、php.ini 寫 extension 名、重啟驗證 php -m。收藏 https://windows.php.net/downloads/pecl/releases/ 這一個站點,覆蓋 99% 生產環境所需擴展。遇到疑難雜症,優先看 php -i 輸出的 Compiler/TS/Architecture,對照文件名逐項核對,必能定位根因。

  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式碼之家 All Rights Reserved