【问题标题】:How to add PHP extension in Windows 10?如何在 Windows 10 中添加 PHP 扩展?
【发布时间】:2020-11-02 12:00:20
【问题描述】:

我已经在我的 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 扩展(从here 下载)。

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

$ 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,have a look

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

【问题讨论】:

  • 您是否安装了 redis 和 mongodb 并启动了这两个服务器。请记住,PHP 扩展只是到这些其他服务器的管道,它们不是 dll 中的实际服务器
  • 是的,我做到了。这两项服务都在我的电脑上运行。是的,我知道.dll 文件只是语言和实际服务之间的桥梁。
  • 您确定这两个扩展与您使用它们的 PHP 是相同的 64 位或 32 位吗?并用兼容的 VC 编译
  • AFAIK,是的。我提供了下载库的下载链接。您可以长按或右键单击它们以查看链接。

标签: php php-extension


【解决方案1】:

研究了一阵子,我发现“线程安全”是PHP世界里的一个THING!我错误地安装了 TS 版本,而我需要 NTS 版本。

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

干杯!

【讨论】:

    猜你喜欢
    • 2017-04-10
    • 2017-11-11
    • 1970-01-01
    • 1970-01-01
    • 2021-04-24
    • 2021-04-06
    • 1970-01-01
    • 2016-07-14
    • 2015-02-07
    相关资源
    最近更新 更多