Welcome, Reviewer!
Reviewer's Guide: Oracle Application Server 10g Standard Edition One
Home Instant Information Sharing Complete Web Site Easy Development Simplified Management
Site Map
Key Features
Demonstrations
Changing the Home Page
Collateral
PHP Extension
Python Extension
White Paper
Technical FAQs
Oracle HTTP Server
OracleAS Web Cache
Oracle and PHP
Oracle PHP Troubleshooting
Installing and Configuring the PHP Extension
 

This document provides installation and configuration notes for the PHP Extension for Oracle JDeveloper.

Contents

Overview

The PHP extension makes it easy to create, edit, and run PHP scripts in Oracle JDeveloper 10g .

This first release of the PHP extension, combined with JDeveloper's comprehensive functionality, increases the PHP developer's productivity in Web and database development. The PHP extension includes the following:

  • PHP, HTML, CSS, XML, JavaScript, SQL, and PL/SQL support
  • Structure view
  • Online Help
  • Presupplied code blocks
  • Database connectivity
  • PL/SQL debugger
  • Database object browser
  • Visual database table creation

The PHP extension can be used in combination with the Application Migration Assistant extension to migrate non-Oracle based PHP applications to an Oracle Database.

Back to Top

Prerequisites

To use all features of the PHP extension in Oracle JDeveloper, you will need to install Oracle JDeveloper, a Web server such as the Apache Web Server, and PHP. You may also need to install an Oracle Database to access a local database, or install Oracle Database Client and arrange accounts on the remote databases you want to access.

Once all software requirements are in place, you can install and use the PHP extension.

Back to Top

Installing the PHP Extension

  1. Download the PHP Extension, php-addin.jar , from the Oracle JDeveloper Extension Exchange at http://www.oracle.com/technology/products/jdev/htdocs/partners/addins/exchange/index.html on the Oracle Technology Network.

  2. Copy php-addin.jar to the jdevhome /jdev/lib/ext directory.

  3. Restart Oracle JDeveloper.

  4. Configure the PHP environment. See the configuration topics on this page or in the PHP extension online Help.

Back to Top

Configuring the Structure Window PHP View

After you install PHP, there are several settings required to enable the Structure window PHP View, as described below.

Setting the PHP Executable

Before Oracle JDeveloper can parse PHP scripts for the Structure window, you need to set the location of the PHP executable in Oracle JDeveloper:

  1. Select Tools > Preferences . The Preferences dialog opens.

  2. Select PHP. The Structure Window PHP View pane opens.

  3. Enter the path and filename of the PHP executable in the PHP Command-line Executable field, or click Browse to find the PHP executable.

Use the command-line PHP executable, not the CGI PHP executable.

For example, if you are using PHP 4.x.x, use the form:
D:\php-4.x.x-Win32\cli\php.exe

If you are using PHP 5.x.x, use the form:
D:\php-5.x-x-Win32\php.exe

  1. Click OK.

If the structure tree does not appear in the Structure window, check that you have set the PHP executable to the command-line PHP executable and not the CGI PHP executable.

Back to Top

Setting PHP View Options

You can disable the PHP View, set it to refresh after the standard Oracle JDeveloper idle-time, or set it to refresh each time you save the script.

To set the PHP View behavior and PHP executable:

  1. Click Preferences in the Tools menu.

  2. Select PHP.

  3. Click the radio button for the PHP View behavior you want.

  4. Enter the path and executable file name of the PHP command-line (cli) executable in the PHP Command-line Executable field, or click Browse to find the file.

    Both the path and filename must be entered. For example, in Windows:

    c:\php4\cli\php.exe for PHP4

    c:\php5\php.exe for PHP5

  5. Click OK to save your settings.

You need to set the command-line PHP executable that the PHP View uses to parse PHP scripts.

Back to Top

Configuring the Environment to Run PHP Scripts

There are several settings that may be required to run PHP scripts and display output in your Web browser:

Setting the Web Browser and Proxy

You may need to modify your browser or proxy settings in the Oracle JDeveloper preferences.

To modify your browser and proxy settings:

  1. Click Preferences in the Tools menu.

  2. Click Web Browser and Proxy.

  3. Enter the browser and proxy settings you want to use. Leave the Browser Command Line field blank to continue to use your default Web browser.

  4. Click Help for further information about the use of these settings.

Back to Top

Configuring Apache Web Server Access to PHP Scripts

The PHP project directory needs to be mapped to the PHP project URL to enable the Web server to display PHP script results in your Web browser. For information about creating a workspace and a PHP project, see Creating a Workspace and Creating a PHP Project in the JDeveloper online Help.

There are several ways to map the PHP project directory containing your PHP scripts to the PHP project URL used by the Web server. Three typical examples are provided below.

Back to Top

Example 1: Default PHP Project

Create a new PHP project using default paths, and then configure the Apache Web Server so it can access PHP scripts created in the default PHP project directory. When you use default paths, the PHP Project wizard typically creates a PHP project directory, for example:

c:\jdev\jdev\mywork\Workspace1\Project1\public_html (Win)

and a PHP Project URL, for example:

http://localhost/Workspace1/Project1/public_html/

You can set an alias parameter in the Apache Configuration file, httpd.conf, so the PHP Project URL maps to the default PHP project directory. For this example, the entry in the Aliases section of httpd.conf is:

Alias /Workspace1/ "c:/jdev/jdev/mywork/Workspace1/" <Directory "c:/jdev/jdev/mywork/Workspace1/">
Options Indexes MultiViews
AllowOverride None
Order allow,deny
Allow from all

</Directory>

If you want to change the PHP Project URL, see Setting and Testing the PHP Project URL .

Back to Top

Example 2: Home Directory as PHP Project Directory

Create a new PHP project and set the PHP Project Directory to your home directory using the ~ (tilde) shortcut. You then need to configure the Apache Web Server so it can access PHP scripts created in the PHP Project Directory. When you set the PHP project directory to your home directory in this way, the PHP Project wizard typically creates a PHP project directory, for example:

/home/username/public_html (Linux)

and a PHP Project URL like:

http://locahost/~username/ (Linux)

where username is the name of your home directory.

You can set a UserDir parameter in the Apache Configuration file, httpd.conf , so the PHP Project URL maps to your PHP project directory. For this example, the entry in the UserDir section of httpd.conf is:

UserDir public_html

If you want to change the PHP Project URL, see Setting and Testing the PHP Project URL .

Back to Top

Example 3: Apache Document Root Directory

Create a new PHP project and set the PHP project directory to the default Apache document root directory, htdocs. The PHP Project wizard typically creates a PHP project directory, for example:

/apache/apache/htdocs/public_html (Linux)

and a PHP project URL, for example:

http://localhost/public_html/

The Apache Web Server accesses PHP scripts in the document root directory by default, so no Apache configuration file changes are necessary.

Back to Top

 

Setting and Testing the PHP Project URL

After the PHP Project wizard has successfully created a PHP project, you can set the PHP project URL in the Project Properties dialog.

To display the output from your PHP script, the PHP Project URL must point to the physical directory containing your PHP scripts, the PHP project directory.

To set and test the PHP project URL:

  1. Select the PHP project in the Application Navigator.

  2. Click Project Properties in the Tools menu.

  3. Expand the Common category and select PHP Script Execution Settings.
    The PHP project URL for the PHP project is displayed.

  4. Enter the PHP project URL you want to use.

  5. Click Test URL to test that the URL is accessible by the Web server. Success or failure messages are displayed in the associated text box. If this is a new project, this test may show failure because the directory structure is not created until the wizard finishes and the project is saved.

Back to Top

Setting the PHP Project Target File

If you attempt to run the PHP project and the target file has not been set, you are prompted to set it.

To set the default PHP project target file:

  1. Click Project Properties in the Tools menu.

  2. In the Project Properties dialog, click Runner under Development in the Profiles node.

  3. Select the PHP project target script to set from the dropdown list in the Default Run Target field, or click Browse to find the script you want to set as the PHP project target script.

  4. Optionally, click the Attempt to Run Active File before Default checkbox if you always want to run the active PHP script rather than the default when you run your PHP project.

  5. Click OK to set this script as the PHP project target file.

Back to Top

Configuring PHP Syntax Colors

You can set syntax colors specific to PHP scripts by setting options for individual PHP styles.

To set PHP syntax colors:

  1. Click Preferences in the Tools menu.

  2. Expand the Code Editor node in the left pane, and select Syntax Colors.

  3. Select PHP from the Language drop down list.

  4. Select the PHP style you want to set from the Available Styles.

  5. Set the font style and the foreground and background colors you want for the selected style.

  6. Repeat steps 4 and 5 for all the PHP styles you want to change.

  7. Click Save as and select an existing Scheme name, or enter a new name.

  8. Click OK to save your settings.

Back to Top

Configuring the PHP Environment

There are several settings that may be required to enable database access in Windows and to view PHP scripts with .phtml and .phps extensions.

Enabling Database Access in PHP on Windows

After installing PHP, ensure it is configured to allow connections to Oracle Database using PHP's OCI8 functions.

To set the extension directory and enable php_oci8.dll in Windows:

  1. Open the php.ini file from the %SYSTEMROOT% directory, which is typically c:\winnt in Windows.

  2. Search for the line containing: ; extension_dir

  3. Uncomment the line by removing the leading semi-colon.

  4. Replace the default directory with the extensions directory of your PHP installation. If you are using PHP 4.x.x, the line will appear in the form:

    extension_dir = "C:\php-4.x.x-Win32\extensions"

    If you are using PHP 5.x.x, it will be in the form:

    extension_dir = "C:\php-5.x.x-Win32\extensions"
  5. Search for the line containing: ;extension=php_oci8.dll
  1. Uncomment the line by removing the leading semi-colon. The line should now appear like: extension=php_oci8.dll

To enable php4ts.dll in PHP 4.x.x:

  1. Stop Oracle JDeveloper.

  2. Navigate to the PHP installation directory.
  3. Copy php4ts.dll to the directory containing the PHP command-line executable, the cli subdirectory of the PHP installation directory. See Setting the PHP executable.
  4. Start Oracle JDeveloper.

Back to Top

Adding PHP Mime Type Definitions to Apache

To enable recognition of PHP scripts with the extension .phps or .phtml, you may need to edit the Apache configuration file, httpd.conf.

To add PHP mime type definitions to Apache:

  1. Stop the Apache Web Server.

  2. Navigate to the APACHE_HOME/apache/conf directory.

  3. Open httpd.conf in a text editor.

  4. Search for .php. You should find a text block similar to the following:

    # Added this section to add a handler for .php scripts.#
    <IfModule mod_php4.c>
    AddType application/x-httpd-php .php
    </IfModule>

  5. Edit the text block to add .phps and .phtml mime types as shown following:

# Added this section to add a handler for .php scripts.#
<IfModule mod_php4.c>
AddType application/x-httpd-php .php
AddType application/x-httpd-php .phtml
AddType application/x-httpd-php-source .phps
</IfModule>

  1. Start the Apache Web Server.

Back to Top

Disabling and Reenabling the PHP Extension

When the PHP Extension is installed, it is automatically enabled. You can use Oracle JDeveloper's Extension Manager to disable it, and subsequently reenable it.

To disable the PHP Extension

  1. Select Tools > Preferences. The Preferences dialog opens.

  2. Select Extension Manager.

  3. Expand System Extensions in the Extensions to Use pane. The PHP Extension is one of the System Extensions displayed.

  4. Click the PHP Extension check box to clear it, and then click OK. You are prompted to allow Oracle JDeveloper to exit.

  5. Start Oracle JDeveloper. The PHP Extension is disabled.

Back to Top

To reenable the PHP Extension

  1. Select Tools > Preferences. The Preferences dialog opens.

  2. Select Extension Manager.

  3. Expand System Extensions in the Extensions to Use pane. The PHP Extension is one of the System Extensions displayed.

  4. Click the PHP Extension check box to check it, and then click OK. You are prompted to allow Oracle JDeveloper to exit.

  5. Start Oracle JDeveloper. The PHP Extension is reenabled.

Back to Top

Uninstalling the PHP Extension

You can uninstall the PHP Extension if you no longer wish to use it. However, if you might want to use it again, consider disabling it instead. See Disabling and Reenabling the PHP Extension .

To uninstall the PHP Extension:

  1. Stop Oracle JDeveloper.

  2. Move or delete php-addin.jar from the jdev_home /jdev/lib/ext directory.

  3. Start Oracle JDeveloper.

Back to Top
   
   
   
   
   
   
   
   
   

Copyright © 2005, Oracle. All rights reserved.
http://www.oracle.com/