This topic has been asked several times, but every solution is not working in my machine.
I am trying to connect windows 7 with a 10G oracle dabatase, but the oci extension is not loaded. Here some facts:
C:\php>php -m
PHP Warning: PHP Startup: Unable to load dynamic library 'C:\php\ext\php_oci8_11g.dll' - %1 is not a valid Win32 application.
C:\php>php -v
PHP 5.6.19 (cli) (built: Mar 2 2016 20:09:42)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
C:\>tnsping localdb
TNS Ping Utility for 32-bit Windows: Version 10.2.0.1.0 - Production on 02-AUG-2
016 22:37:50
Troubleshooting
ext/
folded. The rest of extesions are loaded pretty good.Just looked up for required oracle dll files and they are there:
C:\>where oci*
C:\oracle\product\10.2.0\db_2\BIN\oci.dll
C:\oracle\product\10.2.0\db_2\BIN\ocijdbc10.dll
C:\oracle\product\10.2.0\db_2\BIN\ociw32.dll
What other thing am I missing? Thank you in advance
After months I found the solution. Consider the following infrastructure:
Take close attention when downloading Oracle Instant Client:
Both details are very important. Once I meet both requirements the error has gone I now I am able to connect to Oracle via PHP successfully
Here is a working solution:
<?php echo PHP_INT_SIZE; ?>
If you get 4
, it means you use PHP x86.
If you get 8
, it means you use PHP x64.
Version 11G:
Version 11g, Windows x64 : https://www.oracle.com/technetwork/database/enterprise-edition/downloads/112010-win64soft-094461.html Download Oracle Database 11g Release 2 ***Client*** (11.2.0.1.0) for Microsoft Windows (x64)
.
Version 11g, Windows x86 : https://www.oracle.com/technetwork/database/enterprise-edition/downloads/112010-win32soft-098987.html Download "Oracle Database 11g Release 2 **Client** (11.2.0.1.0) for Microsoft Windows (32-bit)
".
Version 12C:
https://www.oracle.com/technetwork/database/enterprise-edition/downloads/oracle12c-windows-3633015.html Download either
Oracle Database 12c Release 2 Client (12.2.0.1.0) for Microsoft Windows (x64)
or Oracle Database 12c Release 2 Client (12.2.0.1.0) for Microsoft Windows (32-bit)
.
Install Oracle
Find out if you use PHP (TS) Threadsafe version or PHP (NTS) Non-Threadsafe Version. To do so, use the code:
<?php phpinfo(); ?>
Screenshot of phpinfo for TS version
Screenshot of phpinfo for NTS version
If in the value of Zend Extension Build
, you find TS
, you use the Threadsafe (TS) version of PHP.
If in the value of Zend Extension Build
, you find NTS
, you use the Non-Threadsafe (NTS) version of PHP.
DLL
link with the Windows icon in the Downloads
column corresponding to the version of the DLL you need.For PHP version 5.3, 5.4, 5.5 and 5.6, the latest version is 2.0.12
.
For PHP 7.0, it's version 2.1.8
.
For PHP 7.1, 7.2, 7.3, it's version 2.2.0
.
Then, proceed to download the archive corresponding to your PHP version and architecture: if you use PHP 7.2 x86 TS, download the according file: 7.2 Thread Safe (TS) x86
Unzip the downloaded file, in the ext
folder of your PHP installation. Replace old files with new ones.
Enable the PHP OCI8 extension in your php.ini file.
If you installed Oracle 11g, you need to add the folowing line to your php.ini
file:
ext=php_oci8_11g.dll
If you installed Oracle 12c, you need to add the folowing line to your php.ini
file:
ext=php_oci8_12c.dll
NOTE: Only one of the 3 available PCP OCI8 extensions can be enabled at the same time. If you have multiple lines starting with ext=php_oci8
, check that only one is enabled. A disabled line start with a semi-colon. If you find more than one line, delete or comment (add a semi-colon at the begining of the line) the line.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With