简体   繁体   English

PHP8 + Oracle OCI8 => 致命错误:未捕获错误:调用未定义的函数 oci_connect()

[英]PHP8 + Oracle OCI8 => Fatal error: Uncaught Error: Call to undefined function oci_connect()

I have to upgrade an old running and functional app that uses PHP 5.3 32bit, Apache2.2 32bit, Oracle client 11.2 32bit running on Windows 64bit (Win10 for dev, and server for prod).我必须升级一个旧的运行和功能应用程序,它使用 PHP 5.3 32 位、Apache2.2 32 位、Oracle 客户端 11.2 32 位在 Windows 64 位上运行(Win10 用于开发,服务器用于生产)。

The new stack is Apache2.4 32bit, PHP8 32bit and the exact same Oracle client 11.2 32bit.新堆栈是 Apache2.4 32 位、PHP8 32 位和完全相同的 Oracle 客户端 11.2 32 位。

And when I run the webapp, I've got this error at the first DB connection attempt :当我运行 webapp 时,我在第一次数据库连接尝试时遇到了这个错误:

Fatal error: Uncaught Error: Call to undefined function oci_connect() in c:\some\path\connexion_check.php:16 Stack trace: #0 {main} thrown in c:\some\path\connexion_check.php on line 16

My installation was done using these packages :我的安装是使用这些软件包完成的:

  • httpd-2.4.48-win32-VS16.zip httpd-2.4.48-win32-VS16.zip
  • php-8.0.8-Win32-vs16-x86.zip php-8.0.8-Win32-vs16-x86.zip
  • php_oci8-3.0.1-8.0-ts-vs16-x86.zip php_oci8-3.0.1-8.0-ts-vs16-x86.zip
  • php-debug-pack-8.0.8-Win32-vs16-x86.zip php-debug-pack-8.0.8-Win32-vs16-x86.zip

In my PHP.ini file, I have set在我的 PHP.ini 文件中,我已经设置

extension_dir = "ext"
extension=oci8_11g 

There, I use the same parameter as with PHP5.3 => extension=oci8_11g but the DLL was updated with the package php_oci8-3.0.1-8.0-ts-vs16-x86.zip在那里,我使用与 PHP5.3 => extension=oci8_11g 相同的参数,但 DLL 已更新为包 php_oci8-3.0.1-8.0-ts-vs16-x86.zip

Running the command php --ri oci8 says运行命令php --ri oci8

oci8

OCI8 Support => enabled
OCI8 DTrace Support => disabled
OCI8 Version => 3.0.1
Oracle Run-time Client Library Version => 11.2.0.3.0
Oracle Compile-time Instant Client Version => 11.2

Directive => Local Value => Master Value
oci8.max_persistent => -1 => -1
oci8.persistent_timeout => -1 => -1
oci8.ping_interval => 60 => 60
oci8.privileged_connect => Off => Off
oci8.statement_cache_size => 20 => 20
oci8.default_prefetch => 100 => 100
oci8.old_oci_close_semantics => Off => Off
oci8.connection_class => no value => no value
oci8.events => Off => Off

Statistics =>
Active Persistent Connections => 0
Active Connections => 0

Some PHPINFO (from CLI)一些 PHPINFO(来自 CLI)

phpinfo()
PHP Version => 8.0.8

System => Windows NT D20899 10.0 build 19042 (Windows 10) i586
Build Date => Jun 29 2021 15:54:30
Build System => Microsoft Windows Server 2019 Datacenter [10.0.17763]
Compiler => Visual C++ 2019
Architecture => x86
Configure Command => cscript /nologo /e:jscript configure.js  "--enable-snapshot-build" "--enable-debug-pack" "--with-pdo-oci=..\..\..\..\instantclient\sdk,shared" "--with-oci8-19=..\..\..\..\instantclient\sdk,shared" "--enable-object-out-dir=../obj/" "--enable-com-dotnet=shared" "--without-analyzer" "--with-pgo"
Server API => Command Line Interface
Virtual Directory Support => enabled
Configuration File (php.ini) Path =>
Loaded Configuration File => C:\www\php8\php.ini
Scan this dir for additional .ini files => (none)
Additional .ini files parsed => (none)
PHP API => 20200930
PHP Extension => 20200930
Zend Extension => 420200930
Zend Extension Build => API420200930,TS,VS16
PHP Extension Build => API20200930,TS,VS16
Debug Build => no
Thread Safety => enabled
Thread API => Windows Threads
Zend Signal Handling => disabled
Zend Memory Manager => enabled
Zend Multibyte Support => disabled
IPv6 Support => enabled
DTrace Support => disabled

Registered PHP Streams => php, file, glob, data, http, ftp, zip, compress.zlib, compress.bzip2, https, ftps, phar
Registered Stream Socket Transports => tcp, udp, ssl, tls, tlsv1.0, tlsv1.1, tlsv1.2, tlsv1.3
Registered Stream Filters => convert.iconv.*, string.rot13, string.toupper, string.tolower, convert.*, consumed, dechunk, zlib.*, bzip2.*

This program makes use of the Zend Scripting Language Engine:
Zend Engine v4.0.8, Copyright (c) Zend Technologies
    with Xdebug v3.0.4, Copyright (c) 2002-2021, by Derick Rethans

Besides this webapp, I manage/use other apps/tools that connect to my Oracle DB using that same InstantClient installation.除了这个 web 应用程序之外,我还使用相同的 InstantClient 安装管理/使用连接到我的 Oracle 数据库的其他应用程序/工具。 DB connections are ok from this computer using :这台计算机上的数据库连接可以使用:

  • Oracle tools甲骨文工具
  • Powerbuilder 32bit Powerbuilder 32位
  • Python 32bit + cx_Oracle Python 32 位 + cx_Oracle
  • Microsoft Word through Oracle Data Provider for .NET and OLEDB Microsoft Word 通过 Oracle Data Provider for .NET 和 OLEDB

I've checked a lot of things but can't figure out what's wrong.我检查了很多东西,但无法弄清楚出了什么问题。 Thanks for your help :-)谢谢你的帮助 :-)

Edited :编辑:

C:\www\php8>php -m
[PHP Modules]
bcmath
bz2
calendar
Core
ctype
curl
date
dom
filter
hash
iconv
json
libxml
mysqlnd
oci8
openssl
pcre
PDO
Phar
readline
Reflection
session
SimpleXML
SPL
standard
tokenizer
xdebug
xml
xmlreader
xmlwriter
zip
zlib

[Zend Modules]
Xdebug

Hell, I got it.见鬼,我明白了。 Here's the explanation for the next guy who'll come with the same problem...这是对下一个遇到同样问题的人的解释......

Here's some data about my settings :这是有关我的设置的一些数据:

  • C:\\WWW\\ C:\\WWW\\
  • C:\\WWW\\Apache24 C:\\WWW\\Apache24
  • C:\\WWW\\PHP8 C:\\WWW\\PHP8
  • C:\\WWW\\PHP8\\php.exe C:\\WWW\\PHP8\\php.exe
  • C:\\WWW\\PHP8\\php.ini C:\\WWW\\PHP8\\php.ini
  • C:\\WWW\\PHP8\\ext C:\\WWW\\PHP8\\ext
  • C:\\WWW\\PHP8\\ext\\oci8_11g.dll C:\\WWW\\PHP8\\ext\\oci8_11g.dll
  • C:\\WWW\\MyWebApp\\index.php C:\\WWW\\MyWebApp\\index.php

it seemed odd that the extension oci8 didn't come out from phpinfo().扩展 oci8 不是从 phpinfo() 中出来似乎很奇怪。 UsingProcess Monitor i figured out that oci8_11g.dll was searched everywhere (according to PATH env. variable) but not at the right place.使用进程监视器,我发现 oci8_11g.dll 被到处搜索(根据 PATH 环境变量),但不是在正确的位置。

My setting in PHP.INI was this :我在 PHP.INI 中的设置是这样的:

extension_dir = ".\\ext" extension_dir = ".\\ext"

and ProcMon showed that C:\\WWW\\PHP8\\ext was NOT searched into, but rather C:\\WWW\\Apache24\\ext.和 ProcMon 显示 C:\\WWW\\PHP8\\ext 没有被搜索到,而是 C:\\WWW\\Apache24\\ext。

Thus I understood that the folder .\\ext was relative to the Apache httpd.exe process running from C:\\WWW\\Apache24\\bin因此我明白文件夹.\\ext是相对于从 C:\\WWW\\Apache24\\bin 运行的 Apache httpd.exe 进程

So, in my PHP.ini file I changed my value to a absolute path so that it will be compatible in the CLI environnement as well as PHP launched from Apache.因此,在我的 PHP.ini 文件中,我将我的值更改为绝对路径,以便它在 CLI 环境以及从 Apache 启动的 PHP 中兼容。

extension_dir = "c:\\www\\php8\\ext" extension_dir = "c:\\www\\php8\\ext"

After restarting the Apache service, all is fine.重启Apache服务后,一切正常。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法加载oci8 - >致命错误:调用未定义的函数oci_connect() - can not load oci8 -> Fatal error: Call to undefined function oci_connect() 致命错误:调用未定义的函数 oci_connect() php 错误 - Fatal error: Call to undefined function oci_connect() php error PHP中的Oracle连接错误。 致命错误:调用未定义函数oci_connect() - Oracle Connection Error in PHP. Fatal error: Call to undefined function oci_connect() 致命错误:调用Wamp中未定义的函数oci_connect() - Fatal error: Call to undefined function oci_connect() in Wamp 致命错误:调用未定义函数oci_connect() - Fatal error: Call to undefined function oci_connect() 致命错误:未捕获错误:通过命令提示符运行php脚本时调用未定义函数oci_connect() - Fatal error: Uncaught Error: Call to undefined function oci_connect() while running the php script through command prompt 致命错误:在第3行的C:\\ xampp \\ htdocs \\ Project1 \\ connect.php中调用未定义函数oci_connect() - Fatal error: Call to undefined function oci_connect() in C:\xampp\htdocs\Project1\connect.php on line 3 致命错误:在Windows 10上运行的Oracle 10g中,在Wamp Server 3.0中调用未定义函数oci_connect() - Fatal error: Call to undefined function oci_connect() in wamp server 3.0 with oracle 10g running on windows 10 如何修复 wamp 服务器中的错误“未捕获的错误:调用未定义的 function oci_connect()”? - How to fix error “Uncaught Error: Call to undefined function oci_connect()” in wamp server? 致命错误:在第71行的C:\\ xampp81 \\ htdocs \\ aaainc \\ db.php中调用未定义函数oci_connect() - Fatal error: Call to undefined function oci_connect() in C:\xampp81\htdocs\aaainc\db.php on line 71
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM