Plug-in for PHP
This article provides information about installing and configuring IBM® WebSphere® sMash PHP plug-in for Eclipse.
Eclipse is a Java™-based development platform developed by an open community. It includes extensible frameworks and tools for building and managing software throughout its 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
IBM employees should download the Java SDK from the IBM internal site.
- Eclipse PHP Development Tools (All-in-one PDT version 2.0)
Eclipse must be started with version 5.0 (or later) of the JDK.
PDT 1.0.3 is still supported by the WebSphere sMash PHP plug-in, however PDT 2.0 is now recommended.
- Command-line interface (CLI) from LeMans, Sebring, WebSphere sMash DE 1.1 or WebSphere sMash DE 1.0 with fixpack version 1.0.0.3 or later.
Users of WebSphere sMash DE 1.0 with fixpack version 1.0.0.2 or earlier cannot use the latest Eclipse plug-in. These users are encouraged to move up to the latest fixpack.
Important note for silverstone plug-in users
If you have previously installed the WebSphere sMash PHP plug-in from a silverstone update site, you should follow the instructions in the Eclipse Plug-in Migration Guide instead of the Installation and Configuration instructions below.
Installation
Use the following update site to install the WebSphere sMash PHP plug-in.
If you need assistance with this step, open the Eclipse Help browser (Help > Help Contents) and search for the term install.
Configuration
The following instructions assume that you have never installed the WebSphere sMash PHP plug-in, and that you are using a new workspace.
- Download and install a CLI. Please visit the Command-line interface section for details.
- Open a command prompt at the <zerohome> directory.
- Type the following:
-
zero version - This command bootstraps the CLI and prevents unnecessary delays during the Eclipse configuration that follows.
-
- In Eclipse, click Window > Preferences > WebSphere sMash
- In the Zero home field, enter the path to your <zerohome> directory.
- The plug-in will take a few moments to search for the module groups from your CLI.
- After the Loading... message disappears from the Module group field, select the module group that you would like to use for application development. For more information about module groups, please search for the phrase "module group" in the Developer's Guide.
- Click OK to exit the Preferences dialog.
You are now ready to start developing WebSphere sMash applications.
Creating and running an application
To create and then run a WebSphere sMash application, complete the following steps:- Click File > New > Project ....
- Expand the WebSphere sMash category folder near the bottom to see the WebSphere sMash 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 Project Zero icon next to it.
- To run your new application, right-click the project and click Run As > WebSphere sMash Application. This launches the application. A message is 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. - Open a browser and enter
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. Continue reading 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.
In your project tree 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.
You can add dependencies to your project from the local 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 Dependencies 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 Resolved Libraries container in your project tree.
Using WebSphere sMash samples
You can create WebSphere sMash sample applications with the example wizard.
- Click File->New->Example....
- If you have multiple Example types, expand WebSphere sMash Examples.
- Select WebSphere sMash Sample Project and click Next >.
- At this stage, the plug-in loads the available sample projects from the CLI using a background job. It usually takes a few moments for the list to finish loading.
- After the list is loaded, select a sample project and click Next >.
- You can modify the name of the sample project, or use the default name that is provided.
- Click Finish.
See the PHP Employee Demo and Office Monitor Demo documentation for more sample code.
Exporting applications
To export your application, complete the following steps:
- Right-click the project and click Export....
- Expand the WebSphere sMash category.
- Select WebSphere sMash 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.