I have a simple php script:
<?php
$db_user = 'myusername';
$db_pass = 'mypassword';
$db_sid = 'mysid';
$conn = oci_connect( $db_user, $db_pass, $db_sid );
?>
When I run it (from a browser or from the command line), I get the error:
Call to undefined function oci_connect
I'm using php 5.6.6 which came with php_oci8_12c.dll already there.
I have extension=php_oci8_12c.dll
in my php.ini
I have installed instant client (12.1) - tried 32 bit version AND 64 bit version
I have ORACLE_HOME and TNS_ADMIN environment variables pointing at the instant client folder ( C:\instantclient_12_1 ).
I also have C:\instantclient_12_1 in my path
I have a tnsnames.ora in that same folder with this relevant entry in it:
MYSID =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = myhost.net)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = MYSERVICE)
)
)
I have also downloaded SQLDeveloper from http://www.oracle.com/technetwork/developer-tools/sql-developer/downloads/index.html
SQLDeveloper works, recognizes the above mentioned tnsnames.ora and connects and successfully runs a query on the same database that my php script is trying to access.
I have spent several hours over several days trying different things to no avail.
I'm using:
php 5.6.6
windows 8.1
IIS (so no answers involving apache please)
cmd (run as administrator)
Oracle Database 11g Enterprise Edition 11.2.0.3.0
Some other information that might prove useful:
I would ideally like to use oci 1.4.10 to match the production server, but not too worried about that for now.
pear install oci8-1.4.10.tgz
gives me this error:
The DSP oci8.dsp does not exist
I can't find any explanation on that error that means anything to me.
What am I missing - can anyone help me
EDIT:
I have tried the various suggestions in other posts on stackoverflow, namely:
extension=oci8.so
with and without extension=php_oci8_12c.dll
I don't have the line extension=php_oracle.dll
in my php.ini file
EDIT:
phpinfo tells me that I am using the correct php.ini file:
Loaded Configuration File => C:\php5.6.6\php.ini
This line from phpinfo might also be of use:
Configure Command => cscript /nologo configure.js "--enable-snapshot-build" "--enable-debug-pack" "--disable-zts" "--disable-isapi" "--disable-nsapi" "--without-mssql" "--without-pdo-mssql" "--without-pi3web" "--with-pdo-oci=c:\php-sdk\oracle\x86\instantclient_12_1\sdk,shared" "--with-oci8-12c=c:\php-sdk\oracle\x86\instantclient_12_1\sdk,shared" "--with-enchant=shared" "--enable-object-out-dir=../obj/" "--enable-com-dotnet=shared" "--with-mcrypt=static" "--without-analyzer" "--with-pgo"
EDIT:
It seems that dsp files are VC++ project files - I am now venturing on learning how to create a php extension, and hopefully when I've done that I'll have enough knowledge to compile the oci8 1.4.10 source code into a dll that works on windows 8 - unless somebody rescues me with the answer to this question - this looks like it is going to take me some time :-)
EDIT:
Adding display_startup_errors = On
to php.ini tells me that the oci dll is not a valid Win32 application
In addition to what was said to fix the problem, I would like to add the php CLI side of things, as some people need to run OCI-enabled applications in CLI mode. In my case, I had to copy an instance of
oci.dll
into thewamp/bin/php/php<version>/
folder forphp --ri oci8
to show that oci8 was correctly loaded. That doesn't prove that other files were not needed to correctly run a full-fledged application (see my technical footnote). Including the path to the instantclient 12 distribution wouldn't do it.Technical notes: My environment being: Windows 7 + WAMP3 (php 5.6.15, apache 2.4.17), I was, after a number of experiments, able to narrow down the minimal set of three files that needed to be copied to the bin directory (Apache's for non-cli apps) from the instantclient 12 distribution, to allow instantiate an Oracle adapter within Zend Framework, perform an SQL query and read the recordset.
This set is:
oci.dll
,oraociei12.dll
andorans.dll
.In particular, copying just
oci.dll
wouldn't allow the application to work (unknow Exception raised)Edit:
Hmm. Trying this on Windows 8 appears to generate the same error as you specified. I'm currently investigating...My mistake (I had enabled the wrong
extension_dir
line). It works in Win8 just as documented below.The following steps should be all you need to get OCI working with PHP (I've just verified this on a freshly installed Windows 2008 R2 Standard x64 virtual machine):
C:\php
fromphp-5.6.7-nts-Win32-VC11-x86.zip
).C:\instantclient_12_1
frominstantclient-basic-nt-12.1.0.2.0.zip
).c:\php\php.ini-production
toc:\php\php.ini
.php.ini
:extension_dir = "ext"
.extension=php_oci8_12c.dll
.At this point running
php --ri oci8
in a command prompt shows me the following output:And checking for the
oci_connect
function: