With the default installation of XAMPP for Windows, we don’t get PHP Oracle connectivity enabled. This can be enabled easily when you need to connect to a Oracle Database from your PHP application/script. PHP has got the OCI8 extension, which provides Oracle connectivity to PHP application, and OCI8 uses Oracle Instant Client Package to get Oracle specific functions.
I had the need to connect to a Oracle Database from a PHP script in one of my recent projects, the following is what I did to enable Oracle connectivity in XAMPP for Windows.
- In your XAMPP Start Page, go to phpinfo, look for string oci8. If string found it indicate that connection to oracle is available, otherwise to activate connection do the following steps:
- Open the currently used php.ini file by looking at the phpinfo, from the XAMPP folder.
- Find string ;extension=php_oci8.dll. Remove the semicolon (;) ahead of the string to activate the oracle extension.
- Save the php.ini file.
- Download the “Instant Client Package – Basic” for Windows from the OTN Instant Client page. Unzip it to c:\instantclient_11_1
- Edit the PATH environment setting and add c:\instantclient_11_1 before any other Oracle directories. For example, on Windows XP, follow Start -> Control Panel -> System -> Advanced -> Environment Variables and edit PATH in the System variables list.
- Set desired Oracle globalization language environment variables such as NLS_LANG. If nothing is set, a default local environment will be assumed. See An Overview on Globalizing Oracle PHP Applications for more details.
- Unset Oracle variables such as ORACLE_HOME and ORACLE_SID, which are unnecessary with Instant Client (if they are set previously).
- Restart XAMPP (or Start if its not already started).
- To make sure that connection to oracle database has successfully activated, go to phpinfo. Find string: oci8. If found, then XAMPP can now communicate with Oracle Database.
The steps to do the same in a Linux box are almost similar, except there you will use the Linux versions of the packages and setting PATH variables would be different.
You can ping me back with a comment if you run into any issues, I might be able to help you or I can learn from you.