How to use oracle client 11.2 with php (xampp) on win7 x64

37,172

Solution 1

I finally found a solution:

I downloaded the actual OCI-DLLs from "PECL :: PAckage :: oci8 :: 2.0.8" (in my case the 32bit, threadsafe DLL) and then removed the ; from this line

;extension=php_oci8_11g.dll  ; Use with Oracle 11gR2 Instant Client

I also added the following lines to my http.conf of apache

SetEnv ORACLE_BASE "C:/oracle/"
SetEnv ORACLE_HOME "C:/oracle/product/11.2.0/client_1"  

After that I restarted apache, made sure that my connection-alias is probably placed in my tsnames.ora and then I could use the oci8-functions witout any problems.

Solution 2

  1. https://pecl.php.net/package/oci8/2.2.0/windows SELECT -> 7.3 Thread Safe (TS) x86 for 32bits or 7.3 Thread Safe (TS) x64 for 64 bits
  2. Extract all files and copy into de C:\xampp\php\ext
  3. Open php.ini file and write this: extension=php_oci8.dll
  4. Restart xampp. check your browser http://localhost/dashboard/phpinfo.php if the oci8 is enabled if not appear. download from internet and copy the oci8.dll into the c:\windows\system32 folder.
  5. Restart xampp
  6. Check your browser http://localhost/dashboard/phpinfo.php if the oci8 is enabled. Done!!
Share:
37,172
bish
Author by

bish

Playing computer games since childhood I started as a software engineer trainee in the finanical sector after finishing school without had something to do with this anytime before. Since my training I'm addicted to it. After my training I did my B.Sc in computer science parallel to work. On work I mostly do JAVA EE software engeneering, quality assurance and are build manager for our team using Maven and Jenkins pipelines. I'm always looking forward to improve my skills and find ways to make our team work more effecient.

Updated on October 31, 2020

Comments

  • bish
    bish over 3 years

    I just installed an acutal XAMPP on my win7 (x64) PC to write some PHP scripts to connect to an oracle DB. I also have a normal oracle 11.2.0 client installed (PATH and ORACLE_HOME are set correctly). The client is used for all my other work without any problems.

    When I try to connect to an oracle DB PHP fails with Fatal error: Call to undefined function oci_connect() in. I remember I had to enable the "oci8-extensions" in my php.ini when I did the same thing some years ago on a x32 winXP PC. But my current xampp does not have these dll in the php/ext folder (only a php_oci8_12c.dll which throws several errors of unknown functions on apache start and which is for oracle 12 and not 11) and the php.ini also says they are only needed for the instant client.

    ;extension=php_oci8.dll      ; Use with Oracle 10gR2 Instant Client
    ;extension=php_oci8_11g.dll  ; Use with Oracle 11gR2 Instant Client
    

    Also this SO-questions shows that using the comment extension with a normal client will not work (which I also tried).

    I tried to google for a solution but all "solutions" are "install win32 instant client and enable extension". But I can`t do this as most of my QA-work requires the installed and configured 11.2.0-client and I don't have the .dll in my php/ext-folder anyway

    I also tried to copy the ociw32.dll from the client/bin folder to the php/ext-folder but then apache says it's not an PHP-library.

    So how can I enable PHP oracle libraries to use oci8 for XAMPP on x64 win7 WITHOUT installing win32 Oracle Instant Client and destroying my current setting?

    edit: I also tried the steps described in the PHP: Installation Manual (Post of: samantha dot vincent at gmail dot com) including changing my apache-http.conf which also didn't help.

    I'm also confused of my phpinfo()-Output as it says

    Configure Command   "--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"
    
  • Abaij
    Abaij about 9 years
    @bish, please can you tell me where did you put the files you download?
  • bish
    bish about 9 years
    In your php/bin-directory.
  • Virgili Garcia
    Virgili Garcia over 8 years
    with yours downloaded without change http.conf, this tutorials: XAMMP | ORACLE | and PHP.NET
  • Loupi
    Loupi over 8 years
    Hi I was wondering what does the 'SetEnv ORACLE_BASE "C:/oracle/"' do? Is this the Oracle client and not the Instant client?
  • bish
    bish over 8 years
    I used the normal Oracle Client and NOT the instant client as said in the question
  • cijagani
    cijagani almost 8 years
    it was not working before, then what i did? i just copied files orannzsbb11.dll , oci.dll and oraociei11.dll to c:\windows\system32. and restart apache and finally it's working.....:)