O'Reilly logo

Professional PHP Design Patterns by Aaron Saray

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

2.3. Using Eclipse PDT with Patterns

The Eclipse PDT software package is a PHP-centric distribution of the popular Eclipse IDE. With additional features like the PHP perspective, and JavaScript and CSS syntax highlighting, Eclipse PDT is one of the most important tools in my programming arsenal.

The next part of this chapter is based on Eclipse PDT 2.0 in Windows. However, you can use these steps for a standard Eclipse installation as the feature set is common to the core Eclipse distribution. If you use a different IDE and have never tried out PDT, I suggest that you try it out now with this next tutorial. You can acquire the newest PDT package from http://zend.com/pdt. If you continue to use a different IDE, you may be able to adapt these steps to fit your own IDE. (Perhaps you may even want to write these up in your own technical blog!)

2.3.1. Code Snippets in Eclipse PDT

One useful feature in Eclipse PDT is the code snippets function. Snippets allow code templates to be created and inserted into your current file. These can range from a simple code comment template to a complex set of function definitions for a reusable interface.

For this example, we're going to use the SPL Iterator interface. As you build your own library of Design Pattern based modules, you may find you will need to create more code snippets.

2.3.1.1. Creating the Iterator Interface Code

When implementing the Iterator interface, five methods are required to be part of your object: current(), key(),

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required