| | |
|
|
|
Installing and configuring: Eclipse for PHP
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. The following sections of this article provide information about installing and configuring Eclipse for PHP:
Prerequisites
If you choose to develop a Zero application in PHP with Eclipse, the following prerequisites are required:
Installation
To use this platform for developing an application in PHP, follow these installation steps:
- Install the Eclipse PHP Development Tools (PDT) 1.0 release located at http://download.eclipse.org/tools/pdt/downloads/?release=R20070917 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
Zero and enter a URL. The URL should be http://www.projectzero.org/update/zero.eclipse.php.latest.
- Click OK then, Finish.
- Expand the remote site that you defined (called Zero in the example above) 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.
- Now 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
- Click File > New > Project ....
- Expand the Zero category folder near the bottom to see the Project Zero PHP Application project type, as shown in the following graphic.

- 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.
- In a browser go to
http://localhost:8080/ to see the default page of your application.
- To see some details of the request, go to
http://localhost:8080/snoop.php. It will give you a response like this:
- Stop your application.
Congratulations! You've created and run your first Zero 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 Project Zero application using the Simple PHP Zero tutorial.
Resolving libraries
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:
- Double-click the config/ivy.xml file in your project to open the Zero Package Editor as shown below:
2. 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 as shown below:
3. Select the dependency you want to add to the application. For instance 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 has been added to the list.
4. Click Ctrl-S or File > Save to save the modified package information.
5. To see the zero.data.php library added to your classpath as shown below, expand the Zero Resolved Libraries container under your project.
Using Zero Examples
If you installed the Zero Examples plugin, 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
- See the Tutorials and Examples page for more information on using the examples.
Enable logging for the event core
- Edit the
logging.properties file in your installation directory under the config/logging.properties directory.
- 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 zero 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 zero zip file and click 0K.
- Click Finish to import the checked project.
Next steps
For information about developing Project Zero applications using PHP see the PHP Developer's Guide.
|
|
r32 - 25 Oct 2007 - 19:45:52 - paynel
|
|
|
| | |