Installing and configuring: Eclipse for PHP
This article provides information about installing and configuring IBM WebSphere sMash PHP plugin for Eclipse.
Eclipse is an open development platform developed by an open community. It includes extensible frameworks, tools and runtimes for building, deploying and managing software across the life cycle.
Prerequisites
If you choose to develop a WebSphere sMash application in PHP with Eclipse, the following prerequisites are required:
- Windows, Linux, or Mac operating system
- Java SE Development Kit (JDK) 5.0 or 6.0
- Note: IBM employees should download the Java SDK from the IBM internal site.
- Eclipse PHP Development Tools (PDT) 1.0.2
- Note: Eclipse must be started with version 5.0 (or later) of the JDK or download errors will occur.
Installation
To use this platform for developing an application in PHP, follow these installation steps:
- Install the Eclipse PHP Development Tools (PDT) 1.0.2 release located at http://download.eclipse.org/tools/pdt/downloads/?release=R20080103 to develop in PHP.
- The Project Zero plug-in also requires a version 1.5/5.0 (or later) JDK. The bin directory of the 1.5 JDK must be referenced in your PATH environment variable (appearing before any other Java installation). If you do not want to include the 1.5 JDK in your path, then you can start eclipse with a VM argument like
eclipse -vm <path_to_your_JDK>\bin\javaw. (Use '/' for UNIX-based file systems.) - To verify that the correct version of Java is in your PATH, type
java -version. - Start Eclipse and click Window > Open Perspective > Java to change to the Java perspective.
- To configure the update sites in Eclipse do the following:
- Click Help > Software Updates > Find and Install ...
- Select Search for new features to install and click Next >.
- Click New Remote Site ....
- Enter a name like
Zeroand enter a URL. The URL should be https://www.projectzero.org/zero/silverstone/latest/update/zero.eclipse.php - Click OK then, Finish.
- Expand the remote site that you defined (named Zero in the previous step) to see the two plug-in categories under it, Project Zero and Project Zero Examples. Expand the Project Zero category to see Project Zero Feature and Project Zero PDT Feature. The features under Project Zero are required, but the feature under Project Zero Examples is optional.
- Select both features under the Project Zero category. You can optionally select the Project Zero Examples Feature if you would like to work through the examples. Read and accept the license agreements and click Finish.
- Click Install All and then click Yes when asked to restart Eclipse.
Creating and running an application
Use the following steps to create and run an application:
- Click File > New > Project ....
- Expand the Zero category folder near the bottom to see the Project Zero PHP Application project type.
- Select the project type and click Next.
- Enter a name for your new application and click Finish to create it. Your new project is shown with a Zero icon next to it.
- To run your new application, right-click the project and click Run As > Project Zero Application. This launches the application. A message will be displayed in the console indicating that application was started on port 8080.
- Note: All applications use port 8080 by default. If you have another application started, it cannot use the same port. The port is configured in the application's
config/zero.configfile. - In a browser go to
http://localhost:8080/to see the default page of your application. - Stop your application.
Congratulations! You have created and run your first WebSphere sMash application. Now, read on to find out how you can add additional libraries to enhance your application. You can also check out the workings of a WebSphere sMash application using the PHP Employee Demo.
Adding dependencies
WebSphere sMash uses a dependency management utility called Ivy to ensure that your application is using the right versions of the libraries you declare as dependencies. In Ivy, these libraries are called modules, and they are located through a process called dependency resolution. See the documentation on Dependency Management for more information.
Under your project there is a JRE container and the Zero Resolved
Libraries container. The Zero Resolved Libraries container resolves
libraries from configured repositories and adds them to your
classpath
. This container uses an
ivy.xml
file located in the
config
directory to resolve dependencies from
repositories and adds the resolved JAR and ZIP files to your
classpath
.
You can add JAR files to the project
classpath
by copying them into the
lib
directory of the
project, or by adding dependencies from repositories. When a PHP
project is first created, it only has one dependency: zero.php.
A library can be pulled from a repository. The following steps show how this is done by editing the dependency configuration to add the
zero.data.php
library to the project:
- Stop your application if it is currently running. Applications should be stopped before modifying their configuration.
- Double-click the config/ivy.xml file in your project to open the Zero Package Editor.
- Click the Add... button in the Dependencies section of the editor. The dialog that displays allows you to select a dependency from the local repository which was installed with the Eclipse plug-in.
- Select the dependency you want to add to the application. For example, to add a dependency to the PHP Data Zero support add zero:zero.data.php(1.0+) from the list and click OK. The dependency is added to the list.
- Click Ctrl-S or File > Save to save the modified package information.
- To see the zero.data.php library added to your
classpath, expand the Zero Resolved Libraries container under your project.
Using Zero Examples
If you installed the Project Zero Examples plug-in, you can create example Zero projects in your Workspace.
- Click File->New->Example...
- Expand Zero Examples and select Project Zero Example Projects
- Choose one or more examples to create as projects in your Workspace
- You can also look at the PHP Employee Demo or Office Monitor Demo for coding examples.
Enable logging for the event core
- Edit the
logging.propertiesfile in your installation directory under theconfig/logging.propertiesdirectory. - To log all messages for the event engine, add this line:
zero.core.EventEngine.level=FINEST
Exporting applications
To export your application, use the following steps:
- Right-click the project and click Export....
- Expand the Project Zero category.
- Select Project Zero Export Wizard and click Next.
- Click Browse... to select a directory and store the exported zip file.
- Check Include Source to include the source project.
Note: you must include source if you plan to import the project back into Eclipse.
Importing applications
To import a WebSphere sMash application that has the source included (see above), use the following steps:
- Click File > Import > General > Existing Projects into Workspace.
- Click Next.
- Select the Select Archive File radio button.
- Select Browse... to locate your exported WebSphere sMash zip file and click 0K.
- Click Finish to import the checked project.
Next steps
For information about developing WebSphere sMash applications using PHP see the PHP Developer's Guide.