'php throws exception "Call to undefined function oci_connect()"

Here is my configuration: Window Server 2016 build 14393

From phpinfo:

PHP Version 8.1.5 Architecture X64 Server API CGI/FastCGI Loaded configuration file: D:\php\php.ini (expected) PHP API: 20210902 PHP Extension: 20210902

from php.ini extension=oci8_12c ; Use with Oracle Database 12c Instant Client

Notes:
This php.ini file works on my laptop and another windows 16 server (both running Apache). On this server, we are running php over IIS

many of the extension sections are missing from phpinfo listing including oci8 and odbc.

If I do a php --ri I get screenful of warnings telling me for example:

PHP Warning: PHP Startup: Unable to load dynamic library 'curl' (tried: d:\php\ext\curl (The specified module could not be found), d:\php\ext\php_curl.dll (The specified module could not be found)) in Unknown on line 0

but in every case I tested, the 'missing' dll does exist in the specified folder.

execution of tnsping from d:\app\oracle\product\12.2.0\client_1\bin\tnsping.exe:

TNS Ping Utility for 64-bit Windows: Version 12.2.0.1.0 - Production on 28-APR-2022 16:51:58

first part of path:

PATH=C:\Windows\system32\inetsrv;
D:\app\oracle\product\12.2.0\client_1\bin;
C:\Windows\system32;



Solution 1:[1]

I did not determine root cause for why my extensions were not loading. However, I was able to get them to load. Here is what I did:

  1. removed php-cgi entry from IIS fast-cgi section

  2. removed php-cgi entry from IIS http-mapping section

  3. deleted d:\php folder

  4. From IIS manager, added php 7.4 (64 bit) [latest version available in platform manager] using platform manager

  5. enabled OCI8_12c using IIS/PHP Manager -- at this point, my application works

  6. unzipped php 8.15 to d:\php

  7. used IIS/PHP Manager to register new version, pointing to d:\php\php-cgi.ee

  8. used IIS/PHP Manager to enable OCI8_19

  9. restarted IIS -- now my application works fine as php 8.15 under IIS

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Mark Ainsworth