Using Zend_Tool in Eclipse

Zend_Tool is a command line tool released with the latest version of Zend Framework. It will jump-start the development automating some tasks like the creation of an empty project or of a controller class.

Other than from the command line, its possible to use Zend_Tool directly from Eclipse, lets see how.

Use Zend_Tool from Eclipse
Use Zend_Tool from Eclipse

First, download the framework and extract it.

I’ve had trouble with the full package of the 1.8.1 version, its seems to have a corrupted file in the tar.gz archive:
libraryZendToolFrameworkLoaderIncludePathLoaderRecursiveFilterIterator.php0000664
you can resolve the problem simply by renaming it to RecursiveFilterIterator.php

Now in Eclipse or Zend Studio for Eclipse, create and empty php project in a place accessible from your local webserver.

Now go to the “External tool” => “External Tools Configurations” panel to create a quick link to Zend_Tool.

NB: If you are using Zend Studio, you’ll have to remove the filter that hide “Program” item first:

In Zend Studio remove the filters that hide the Program item
In Zend Studio remove the filters that hide the Program item

Now you can create a new “external tool”:

  1. Click the new item button
  2. Give it a name
  3. Point it to the location of the binzf.bat file in your zend framework folder (where you have extracted it) using the Browse File System button
  4. Set the working directory to the location of your newly created php project with the Browse Workspace button
  5. In the arguments box insert ${string_prompt}. In this way Eclipse will prompt for input when you’ll start the tool.
Create an External Tool in Eclipse
Create an External Tool in Eclipse

Now in the “Enviroment” tab, configure two enviroment variable:

  • Path: to your php.exe folder
  • ZEND_TOOL_INCLUDE_PATH_PREPEND: to your Zend Framework library folder

In the Common tab check Display in favorites menu and in the “Refresh” tab check Refresh resources upon completion => The project containing the selected resource

Now you can run it, and in the dialog write show version. In the Eclipse console you’ll see the zend framework version.

Now you can experiment all the Zend_Tool commands of your choice:

create project [absolute path of your project]
create controller [name of the controller]

And don’t forget that you can create your own Zend_Tool command too.

8 thoughts on “Using Zend_Tool in Eclipse

  1. Pingback: abcphp.com

  2. Rich says:

    Great how-to!

    fyi . . .to get this to work in linux . . .replace zf.bat with zf.sh and you’ll be good. . . .

    Thanks again!
    Rich

  3. Gabriela says:

    I got this message ‘”php.exe”‘ is not recognized as an internal or external command,
    operable program or batch file.

  4. Madarco says:

    @Gabriela: in the Enviroment tab, have you setted the variable “Path” with the absolute path of your php.exe file? (for example: “C:xampplitephp”)

  5. Mario Guenterberg says:

    Hi…
    if you use the comming Galileo Eclipse release, then you must set the Working Directory to ${workspace_loc} without the :/XXXXX stuff, otherwise eclipse gives an error: Variable references non-existent resource : ${workspace_loc:/ZendToolTest}!

    Without the :/XXXX it works great!

  6. Oliver says:

    @Mario Guenterberg: I’ve been using Galileo on about three projects in the last two weeks and don’t have the same experience as you: everything works when I include the ;/ProjectFoo… and wouldn’t otherwise.

    It sounds like you must structure your projects differently, because omitting the reference would mean that the tool simply created the file structure in the workspace root.

Comments are closed.