I have a simple php script:
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 the wamp/bin/php/php<version>/
folder for php --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
and orans.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
from php-5.6.7-nts-Win32-VC11-x86.zip
).C:\instantclient_12_1
from instantclient-basic-nt-12.1.0.2.0.zip
).c:\php\php.ini-production
to c:\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:
C:\>php --ri oci8
oci8
OCI8 Support => enabled
OCI8 DTrace Support => disabled
OCI8 Version => 2.0.9
Revision => $Id: f5a3ee1083d1ffa6adb5143efda6eafa210b8414 $
Oracle Run-time Client Library Version => 12.1.0.2.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
And checking for the oci_connect
function:
C:\>php -r "var_dump(function_exists('oci_connect'));"
bool(true)