Madarco

Using Zend_Tool in Eclipse

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.

Share this post

Comments (8)

  • Pingback: abcphp.com

  • Rich Reply

    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

    May 26, 2009 at 4:36 pm
  • Gabriela Reply

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

    June 4, 2009 at 4:53 am
  • Madarco Reply

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

    June 4, 2009 at 8:47 am
  • Chris MacPherson Reply

    Fantastic tip! Cheers.

    June 18, 2009 at 12:32 am
  • Mario Guenterberg Reply

    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!

    June 18, 2009 at 1:05 pm
  • Oliver Reply

    @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.

    June 21, 2009 at 2:11 am
  • Oliver Reply

    @Madarco: many thanks for the awesome tip BTW… such a time saver!

    June 21, 2009 at 2:12 am

Leave a comment

Your email address will not be published.