This document provides installation and configuration notes for the PHP Extension for Oracle JDeveloper.
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
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
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.
Copy php-addin.jar to the jdevhome /jdev/lib/ext directory.
Restart Oracle JDeveloper.
Configure the PHP environment. See the configuration topics on this page or in the PHP extension online Help.
Back to Top
After you install PHP, there are several settings required to enable the Structure window PHP View, as described below.
Before Oracle JDeveloper can parse PHP scripts for the Structure window, you need to set the location of the PHP executable in Oracle JDeveloper:
-
Select Tools > Preferences . The Preferences dialog opens.
-
Select PHP. The Structure Window PHP View pane opens.
- 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
- 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
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:
-
Click Preferences in the Tools menu.
-
Select PHP.
-
Click the radio button for the PHP View behavior you want.
-
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
-
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
There are several settings that may be required to run PHP scripts and display output in your Web browser:
You may need to modify your browser or proxy settings in the Oracle JDeveloper preferences.
To modify your browser and proxy settings:
-
Click Preferences in the Tools menu.
-
Click Web Browser and Proxy.
-
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.
- Click Help for further information about the use of these settings.
Back to Top
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
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:
-
Select the PHP project in the Application Navigator.
-
Click Project Properties in the Tools menu.
-
Expand the Common category and select PHP Script Execution Settings.
The PHP project URL for the PHP project is displayed.
-
Enter the PHP project URL you want to use.
- 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
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:
-
Click Project Properties in the Tools menu.
-
In the Project Properties dialog, click Runner under Development in the Profiles node.
-
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.
-
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.
-
Click OK to set this script as the PHP project target file.
Back to Top
You can set syntax colors specific to PHP scripts by setting options for individual PHP styles.
To set PHP syntax colors:
-
Click Preferences in the Tools menu.
-
Expand the Code Editor node in the left pane, and select Syntax Colors.
-
Select PHP from the Language drop down list.
-
Select the PHP style you want to set from the Available Styles.
-
Set the font style and the foreground and background colors you want for the selected style.
-
Repeat steps 4 and 5 for all the PHP styles you want to change.
-
Click Save as and select an existing Scheme name, or enter a new name.
-
Click OK to save your settings.
Back to Top
There are several settings that may be required to enable database access in Windows and to view PHP scripts with .phtml and .phps extensions.
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:
-
Open the php.ini file from the %SYSTEMROOT% directory, which is typically c:\winnt in Windows.
-
Search for the line containing: ; extension_dir
-
Uncomment the line by removing the leading semi-colon.
-
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"
- Search for the line containing: ;extension=php_oci8.dll
- 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:
-
Stop Oracle JDeveloper.
- Navigate to the PHP installation directory.
- 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.
- Start Oracle JDeveloper.
Back to Top
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:
-
Stop the Apache Web Server.
-
Navigate to the APACHE_HOME/apache/conf directory.
-
Open httpd.conf in a text editor.
-
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>
- 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>
- Start the Apache Web Server.
Back to Top
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.
-
Select Tools > Preferences. The Preferences dialog opens.
-
Select Extension Manager.
-
Expand System Extensions in the Extensions to Use pane. The PHP Extension is one of the System Extensions displayed.
-
Click the PHP Extension check box to clear it, and then click OK. You are prompted to allow Oracle JDeveloper to exit.
- Start Oracle JDeveloper. The PHP Extension is disabled.
Back to Top
-
Select Tools > Preferences. The Preferences dialog opens.
-
Select Extension Manager.
-
Expand System Extensions in the Extensions to Use pane. The PHP Extension is one of the System Extensions displayed.
-
Click the PHP Extension check box to check it, and then click OK. You are prompted to allow Oracle JDeveloper to exit.
-
Start Oracle JDeveloper. The PHP Extension is reenabled.
Back to Top
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:
-
Stop Oracle JDeveloper.
-
Move or delete php-addin.jar from the jdev_home /jdev/lib/ext directory.
-
Start Oracle JDeveloper.
Back to Top
|