I have been struggling for the last few days to get PHP to connect to an oracle DB. I have been doing this with a MAMP stack installed on a window machine (it is available for windows and ensures a uniform development stack for our team). After struggling with the common problems related to the OCI8 installation I finally got it to show in phpinfo() with the following information OCI8 PHP info section
I can also see it as an installed module using the php -m command, the options using the php --ri oci8 command, and can find the installed dll files from the oracle instant client using where oci*
It appears to be installed and I have a PATH variable linked to the instant client folder. There are no errors besides the call to undefined function in the MAMP log files.
I have not set the ORACLE_HOME, TNS_ADMIN or other oracle variables as they are not needed with the instant client libraries (my understanding)
I have uncommented the lines for the extension_dir and the extension=php_oci8_12c.dll in the php.ini file and have confirmed that I have been editing the correct file.
I have ran a simple php script in an index.php file containing the following lines
<?php
If(function_exists('oci_connect')){
echo 'oci_connect exists';
$conn = oci_connect();
}
?>
This is a simple test which should give me a warning complaining about improper parameters however the output of the script is
oci_connect exists
Fatal error: Uncaught Error: Call to undefined function oci_connect() in C:\MAMP\htdocs\Oracle_Connection\index.php:16 Stack trace: #0 {main} thrown in C:\MAMP\htdocs\Oracle_Connection\index.php on line 16
I have run out of ideas on what might be wrong, none of the documentation in reference to setting up the OCI8 functionality seems to run into this issue.
Any help would be welcome. Thanks
Output from cmd
C:\Users\geoff>php -m
[PHP Modules]
bcmath
calendar
com_dotnet
Core
ctype
date
dom
filter
hash
iconv
json
libxml
mcrypt
mysqlnd
oci8
odbc
openssl
pcre
PDO
pdo_mysql
Phar
Reflection
session
SimpleXML
soap
sockets
SPL
standard
tidy
tokenizer
wddx
xml
xmlreader
xmlwriter
zip
zlib
[Zend Modules]
C:\Users\geoff>php function_exists
Could not open input file: function_exists
C:\Users\geoff>php --ri oci8
oci8
OCI8 Support => enabled
OCI8 DTrace Support => disabled
OCI8 Version => 2.1.4
Revision => $Id: 03698b2e9b50593039b7ca292b2e3cf9eaf064b9 $
Oracle Run-time Client Library Version => 12.2.0.1.0
Oracle Compile-time Instant Client Version => 12.1
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
C:\Users\geoff>where oci*
C:\Oracle\instantclient_12_2\oci.dll
C:\Oracle\instantclient_12_2\oci.sym
C:\Oracle\instantclient_12_2\ocijdbc12.dll
C:\Oracle\instantclient_12_2\ocijdbc12.sym
C:\Oracle\instantclient_12_2\ociw32.dll
C:\Oracle\instantclient_12_2\ociw32.sym