How does one configure PHP to use Oracle?

Follow these steps to prepare your PHP installation for connecting to Oracle databases:

  • Download PHP from www.php.net, install as per the install.txt file, and test if everything is working.

  • Install the Oracle Client (or Server) software on your machine and configure SQL*Net to connect to your database(s). See the SQL*Net FAQ for details.

  • Edit your php.ini file and uncomment the following two lines (only if your version shipped with pre-compiled extension modules):

    ;extension = php_oci8.dll
    ;extension = php_oracle.dll

    ... otherwise, compile PHP with the following options:

    --with-oracle=/path/to/oracle/home/dir
    --with-oci8=/path/to/oracle/home/dir

  • Ensure that your "extension_dir" parameter (in php.ini) points to the location where the above extension files reside.

  • Write a small program to test connectivity - see the next question.