Sunday, July 19, 2009

Setting up an Oracle an PHP development environment

There are a number of tutorials on setting up php and mysql. And there are awesome projects e.g. WAMP and XAMPP to get you started quickly.

I use Nusphere's PHP ed as my programming tool. It is simply the best php environment (at least about an year back ... when I researched into the options available).

There is also an article explaining the process on OTN:
http://www.oracle.com/technology/pub/notes/technote_php_instant.html

However as per my observation I did not need to replace the php_oci8.dll . In fact doing so cause my php code to break.

Heres what I did to get it running:
  • Install Nusphere's PHP ed.
  • Modify php.ini (c:\Program Files\NuSphere\PhpED\php5\php.ini) that is formed uncommenting the line : extension=php_oci8.dll
  • Extract the instant client (I tried : instantclient-basiclite-win32-10.2.0.5.zip from http://www.oracle.com/technetwork/topics/winsoft-085727.html ) to c:\instantclient_10_2
  • Put c:\instantclient_10_2 in your PATH
  • If you are going to use TNSNAMES.ora you can put it in c:\instantclient_10_2 and add a system environment variable TNS_ADMIN and SQL_PATH pointing both to c:\instantclient_10_2
That is it. You are all set.

Say you have an entry in tnsnames.ora as :


RX =
  (DESCRIPTION = (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 150.236.167.30)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SID = 69333)
    )
  )



Just put the IP .. e.g HOST=150.236.161.1
You can now do a simple connect via:

$conn = @OCILogon($user,$password , "rx") or die ("Database Connection Error in file...");