Plug-in 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

Update site

https://www.projectzero.org/zero/silverstone/M1/update/zero.eclipse.php

Detailed instructions

To use this platform for developing an application in PHP, follow these installation steps:

  1. 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.
  2. The WebSphere sMash 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.)
  3. To verify that the correct version of Java is in your PATH, type java -version .
  4. Start Eclipse and click Window > Open Perspective > Java to change to the Java perspective.
  5. To configure the update sites in Eclipse do the following:
    1. Click Help > Software Updates > Find and Install ...
    2. Select Search for new features to install and click Next >.
    3. Click New Remote Site ....
    4. Enter a name like WebSphere sMash and enter a URL. The URL should be https://www.projectzero.org/zero/silverstone/M1/update/zero.eclipse.php
    5. Click OK then, Finish.
  6. Expand the remote site that you defined (named WebSphere sMash in the previous step) to see the two plug-in categories under it, WebSphere sMash and WebSphere sMash Examples. Expand the WebSphere sMash category to see WebSphere sMash Feature and WebSphere sMash PDT Feature. The features under WebSphere sMash are required, but the feature under WebSphere sMash Examples is optional.
  7. Select both features under the WebSphere sMash category. You can optionally select the WebSphere sMash Examples Feature if you would like to work through the examples. Read and accept the license agreements and click Finish.
  8. 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:

  1. Click File > New > Project ....
  2. Expand the WebSphere sMash category folder near the bottom to see the WebSphere sMash PHP Application project type.
  3. Select the project type and click Next.
  4. Enter a name for your new application and click Finish to create it. Your new project is shown with a Project Zero icon next to it.
  5. To run your new application, right-click the project and click Run As > WebSphere sMash Application. This launches the application. A message will be displayed in the console indicating that application was started on port 8080.
  6. 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.config file.
  7. In a browser go to http://localhost:8080/ to see the default page of your application.
  8. 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 Resolved Libraries container. The 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:

  1. Stop your application if it is currently running. Applications should be stopped before modifying their configuration.
  2. Double-click the config/ivy.xml file in your project to open the Dependencies Editor.
  3. 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.
  4. 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.
  5. Click Ctrl-S or File > Save to save the modified package information.
  6. To see the zero.data.php library added to your classpath , expand the Resolved Libraries container under your project.

Using WebSphere sMash Examples

If you installed the WebSphere sMash Examples plug-in, you can create example WebSphere sMash projects in your Workspace.

  1. Click File->New->Example...
  2. Expand WebSphere sMash Examples and select WebSphere sMash Example Projects
  3. Choose one or more examples to create as projects in your Workspace
  4. You can also look at the PHP Employee Demo or Office Monitor Demo for coding examples.

Enable logging for the event core

Exporting applications

To export your application, use the following steps:

  1. Right-click the project and click Export....
  2. Expand the WebSphere sMash category.
  3. Select WebSphere sMash Export Wizard and click Next.
  4. Click Browse... to select a directory and store the exported zip file.
  5. 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:

  1. Click File > Import > General > Existing Projects into Workspace.
  2. Click Next.
  3. Select the Select Archive File radio button.
  4. Select Browse... to locate your exported WebSphere sMash zip file and click 0K.
  5. Click Finish to import the checked project.

Next steps

For information about developing WebSphere sMash applications using PHP see the PHP Developer's Guide.

Version 1.1.0.0.21442