How to enable Oracle Connection to PHP on XAMPP (on Windows)

1. Install XAMPP on your Windows machine. We were using the latest one v5.6.14 (you can download the same from here) on Windows XP.

2. Extract InstantClient to C:\instantclient_<version_no> folder (You can download the same from here)

3. Open system setting at Start Menu > My Computer (right click on the icon) > Select Properties > Advanced Tabs > Environment Variables.

4. Add to ‘System Variables’ by clicking ‘New’ button and insert the following values:

a. Variable Name : PATH

b. Variable Value : C:\instantclient_<version_no>

5. Click OK to accept new modification.

6. Open C:\xampp\php\php.ini by using notepad/any other text editor.

7. Find string oci8 and remove the ; symbol at the beginning of the string line.

8. Save and Exit.

9. Restart Apache server to accept new modification on xampp.


To Check if Oracle connection support is loaded or not-

1. Open web browser.

2. In the address section type http://localhost/xampp

3. Once page load, select phpinfo() menu from the link on the left section of the page.

4. Try to find string OCI8 by using the search function of your browser(or by using CTRL+F).

5. If there is string found on OCI in your phpinfo() page. Then you can start connection to your oracle database.


PHP code to connect to Oracle

1. Open notepad/your text editor

2. Type following code:



If (!conn)

  echo “Failed to connect to Oracle”;


  echo “Succesfully connected with Oracle DB”;


3. Save and exit the text files as : connection.php(All Files Category) at C:\xampp\htdocs\

4. Once saved, please open browser and enter URL http://localhost/connection.php

5. If you see Text stating “Successfully connected with Oracle DB“ , then you are good to go.


Ref: stackoverflow

Link Php of XAMPP to system default (Ubuntu)

We use XAMPP, however the php installation location of XAMPP is separate from what is used when php is installed via command line.
After a full clean up of the installation,

We tried to link up Php in XAMPP to be used as system default, ie like the default php, from terminal php command will execute the xampp version of php.. and we don’t have to write the full path everytime we use php from command line!

The first command we executed was

sudo ln -s /opt/lamp/bin/php /usr/bin/php

However after this even, the changes were not reflected via terminal

Then we did some changes in the bash.

gedit ~/.bashrc

Appended the following to the last line

export PATH=/opt/lampp/bin:$PATH

and saved the file and exited.

Now when we do echo $PATH in the terminal, we see that /opt/lampp/bin has been included.

Now we do a php -v from command line. And woah PHP runs properly! The version currently in our xammp installation is 5.6.


Note: We are using Ubuntu 12.04 LTS

Delete PHP from Ubuntu Installation

Below are the commands that will delete the default php installation from your system. The commands worked well with Ubuntu 12.04 LTS

bash -c "sudo apt-get remove php*"

sudo apt-get remove --purge php-pear php5-cli php5-common php5-curl php5-fpm php5-gd php5-intl php5-mysql php5-pspell php5-readline php5-recode php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl

sudo aptitude remove ~iphp