Function call undefined oci_connect, php_oci8_12c.dll, windows 8.1, php5.6.6

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 the browser or from the command line), I get an error message:

 Call to undefined function oci_connect 

I am using php 5.6.6, which has already appeared with php_oci8_12c.dll.

I have extension=php_oci8_12c.dll in my php.ini

I installed the instant client (12.1) - I tried the 32-bit version and the 64-bit version

I have ORACLE_HOME and TNS_ADMIN environment variables pointing to the client folder (C: \ instantclient_12_1).

I also have C: \ instantclient_12_1 in my path

I have tnsnames.ora in the same folder with this corresponding entry:

 MYSID = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = myhost.net)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = MYSERVICE) ) ) 

I also downloaded SQLDeveloper from http://www.oracle.com/technetwork/developer-tools/sql-developer/downloads/index.html

SQLDeveloper works, recognizes the above tnsnames.ora and connects and successfully runs the query in the same database that my php script is trying to access.

I spent several hours for several days trying to figure it out to no avail.

I use:

 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 information that may be helpful:

Ideally, I would like to use oci 1.4.10 to map to a production server, but have not worried too much about it yet.

 pear install oci8-1.4.10.tgz 

gives me this error:

 The DSP oci8.dsp does not exist 

I can not find any explanation for this error, which means something to me.

What am I missing - can someone help me

EDIT:

I have tried various suggestions in other stackoverflow posts, namely:

extension=oci8.so with and without extension=php_oci8_12c.dll

I do not have extension=php_oracle.dll in 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 may also be useful:

 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. Now I decide to learn how to create a php extension, and I hope when I do that I will have enough knowledge to compile the source code of oci8 1.4.10 in a dll that works on Windows 8 - if someone does not save me the answer to this question - it looks like it will take me some time :-)

EDIT:

Adding display_startup_errors = On to php.ini tells me that oci dll is not a valid Win32 application

+5
source share
2 answers

Edit: Hmm. Trying this on Windows 8 seems to generate the same error as you indicated. I'm studying now ...

My mistake (I included the wrong extension_dir line). It works in Win8 as described below.


The following steps should be all that you need to get OCI to work with PHP (I just checked this on the newly installed Windows 2008 R2 Standard x64 virtual machine):

  • Download and extract PHP (I used C:\php from php-5.6.7-nts-Win32-VC11-x86.zip ).
  • Download and extract InstantClient (I used C:\instantclient_12_1 from instantclient-basic-nt-12.1.0.2.0.zip ).
  • Add the specified paths to the system path.
  • Copy c:\php\php.ini-production to c:\php\php.ini .
  • in php.ini :
    • extension_dir = "ext" string is included.
    • the extension=php_oci8_12c.dll line is included.
  • Set the runtime of Microsoft Visual C ++ 2010 (x86). This is necessary for the OCI8 extension.
  • Set the runtime of Microsoft Visual C ++ 2012 (x86). This is necessary for PHP.

At this point, running php --ri oci8 on the command line 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 check the oci_connect function:

 C:\>php -r "var_dump(function_exists('oci_connect'));" bool(true) 
+10
source

In addition to what was said to fix the problem, I would like to add the php CLI side, as some people need to run applications with OCI support in CLI mode. In my case, I had to copy the oci.dll instance to the wamp/bin/php/php<version>/ php --ri oci8 for php --ri oci8 to show that oci8 was loaded correctly. This does not prove that other files are not needed to properly run a full-fledged application (see My technical footnote). Enabling the instantclient 12 distribution path would not do this.

Technical notes: My environment: Windows 7 + WAMP3 (php 5.6.15, apache 2.4.17), after several experiments, I was able to narrow down the minimum set of three files that needed to be copied to the bin directory (Apache for applications other than cli) from the instantclient 12 distribution to create an instance of the Oracle adapter in the Zend Framework, execute an SQL query and read a set of records.

This set: oci.dll , oraociei12.dll and orans.dll .

In particular, copying only oci.dll will not allow the application to work (it is not known that the exception was raised)

+2
source

Source: https://habr.com/ru/post/1216093/


All Articles