首页 > 解决方案 > 如何在 Windows 10 中添加 PHP 扩展?

问题描述

我已经在我的 Windows 10 PC 上从Chocolatey下载了 PHP 版本。我试图安装并激活PHP Redis扩展,所以我下载了存档,将php_redis.dll扩展文件复制到默认ext文件夹并修改了php.ini文件,如下所示:

;;;;;;;;;;;;;;;;;;;;;;
; Dynamic Extensions ;
;;;;;;;;;;;;;;;;;;;;;;

; If you wish to have an extension loaded automatically, use the following
; syntax:
;
;   extension=modulename
;
; For example:
;
;   extension=mysqli
;
; When the extension library to load is not located in the default extension
; directory, You may specify an absolute path to the library file:
;
;   extension=/path/to/extension/mysqli.so
;
; Note : The syntax used in previous PHP versions ('extension=<ext>.so' and
; 'extension='php_<ext>.dll') is supported for legacy reasons and may be
; deprecated in a future PHP major version. So, when it is possible, please
; move to the new ('extension=<ext>) syntax.
;
; Notes for Windows environments :
;
; - Many DLL files are located in the extensions/ (PHP 4) or ext/ (PHP 5+)
;   extension folders as well as the separate PECL DLL download (PHP 5+).
;   Be sure to appropriately set the extension_dir directive.
;
extension=bz2
extension=curl
extension=ffi
extension=ftp
extension=fileinfo
extension=gd2
extension=gettext
extension=gmp
extension=intl
extension=imap
extension=ldap
extension=mbstring
extension=exif      ; Must be after mbstring as it depends on it
extension=mysqli
;extension=oci8_12c  ; Use with Oracle Database 12c Instant Client
extension=odbc
extension=openssl
;extension=pdo_firebird
extension=pdo_mysql
;extension=pdo_oci
extension=pdo_odbc
extension=pdo_pgsql
extension=pdo_sqlite
extension=pgsql
extension=shmop

; The MIBS data available in the PHP distribution must be installed.
; See http://www.php.net/manual/en/snmp.installation.php
;extension=snmp

extension=soap
extension=sockets
extension=sodium
extension=sqlite3
extension=tidy
extension=xmlrpc
extension=xsl

; Added by Rumon:
extension=mongodb
extension=redis

也按照相同的路径安装mongodb扩展程序(从此处下载)。

现在,当我执行与这些驱动程序相关的任何操作时,我会收到系统找不到扩展的错误消息。例如:

$ php --ini
PHP Warning:  PHP Startup: Unable to load dynamic library 'mongodb' (tried: ext\mongodb (The specified module could not be found.), ext\php_mongodb.dll (The specified module could not be found.)) in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library 'redis' (tried: ext\redis (The specified module could not be found.), ext\php_redis.dll (The specified module could not be found.)) in Unknown on line 0
Configuration File (php.ini) Path:
Loaded Configuration File:         C:\tools\php74\php.ini
Scan for additional .ini files in: (none)
Additional .ini files parsed:      (none)

为了大家方便,我提供了一个SS的扩展目录,大家看看

谁能解释导致问题的原因?我该如何解决这个问题?

标签: phpphp-extension

解决方案


经过一段时间的研究,我发现“线程安全”是PHP 世界中的一个东西!我错误地安装了 TS 版本,而我需要 NTS 版本。

致大家:当您尝试安装任何 PHP 扩展时,请检查您的系统并确保您下载了适当的 (TS/NTS) 版本。

干杯!


推荐阅读