Increase PHP programming productivity with Zend Studio


Author: Peter J. Manis

Looking for an integrated development environment (IDE) for your PHP coding? Zend Studio, which launched its latest version 5.5 in December, offers an impressive feature list that can increase the productivity of even novice programmers.

Zend Studio is a Java application, which means it can run on any OS that supports Java. Many Java applications tend to run slowly, but I noticed no major performance difference in Zend Studio compared to similar applications. By default Zend Studio is configured to use the look and feel of your current operating system’s theme, making it easy on the eyes.

When you first install Zend Studio you must select the PHP version you will be developing for most often. Your selection will affect the code completion, syntax highlighting, local debugging, and other version-specific features. Unfortunately you can’t override this selection on a per-file basis, but you can change the version at a later date in the Preferences dialog under the Desktop tab.

The preferences dialog includes an incredible number of options for customizing Zend Studio. For instance, under its Editing tab are common options such as tab size, replacing tabs with spaces, strip trailing spaces, and Windows or Unix file format, along with options for code folding, character highlighting, and auto-completion.

Code folding, in which certain portions of a program are hidden from view, is a great feature, but many applications lack the option to select which portions of code will be automatically collapsed on loan; it was always all or none. In the latest version, Zend Studio gives you the choice of what should auto-collapse on load. When you are working with an unfamiliar script, code folding combined with the ability to go directly to a function definition in another file can greatly improve your ability to decipher what is really happening.

That still leaves a hole when sloppy code comes into play. Highlighting, sometimes known as brace matching, attempts to improve readability by highlighting the opening and closing characters of control structures, quotes, and parenthesis. You are given the option to select which characters you would like to have highlighted, but the software does not give you the option to highlight the code between the characters.

Zend’s Studio allows you to select which characters, tags, and structures will be automatically closed after you write the opening portion of code. Personally, I don’t like having my quotes or HTML tags automatically closed, but I do prefer to auto-complete parenthesis, brackets, and braces.

Furthermore, under Code Completion, you can disable or enable the display of functions, objects, classes, and variables in the current file, including files that are in the project or in included files.

Code completion dropdown and reference – click to enlarge

This screenshot shows how Zend Studio handles code completion. Here, $pmail is referencing the PHPMailer class, so anything involving $pmail will display classes, functions, and variables related to PHPMailer. It will show the class and the function or variable along with the arguments and their type. If the function, class, or variable has been properly documented, the drop-down box will be followed with a box detailing the parameters of the function, a description, and any additional information provided in the documentation. All of these classes, functions, and variables are also available for viewing in the Inspector box shown on the left.

In addition to these useful features, Zend Studio offers a tabbed interface for files, a WSDL generator, full support for PHP Documentor, and powerful debugging capabilities.

Zend Studio offers templates to simplify reusing common blocks of code. When you are inside a file you simply type a template name and press the Tab key in order to insert the contents of that template at the cursor position of the file. Within the template you may have designated variables. After the template has been inserted the first variable should be highlighted and have a red box around it. When you start typing, the variable name will be replaced with your text. You can then press Tab again to move to the next section. Templates can help save you from copying and pasting large blocks of code or editing multiple variables within code snippets.

Source control and revision diff – click to enlarge

Zend Studio integrates Subversion and CVS for source control. On the left of this figure you can see the context menu that is displayed when you right-click a file. If the file has been checked out from a repository, you will have the Subversion (or CVS) menu at the bottom, and if that file was modified, the Commit option will be enabled. When you run a commit command, the software will display a dialog giving you the option to enter a log message along with additional commit options. Figure 2 also shows us how Zend displays the Diff viewer for Subversion.

Zend Studio also incorporates a simple database browser and the ability to use an FTP server as if it were a local hard drive. On the File menu you can add an FTP, SFTP, or FTP over SSL connection by clicking Add FTP Server. After you define it, the FTP server will show up in your File Manager under the File System tab and will operate as if it were a local hard drive. When you save a file to it, Zend Studio will automatically log in to the FTP server and overwrite the file on the server.

Two final noteworthy features are the Code Snippet gallery and the ability to clone the view of a file. The Zend Web site has a developer section displaying snippets contributed by users from around the world. These snippets have been integrated into Zend Studio via a snippet gallery that directly interacts with the Web site. Under the Edit menu, select Show Snippets and update the snippet file. You will then have a large repository of snippets to insert in your scripts and the ability to add your favorite snippets for future use.

Snippet gallery and clone view – click to enlarge

Clone View allows you to edit the same file in multiple windows, keeping them in sync at all times, eliminating the need to scroll back and forth from section to section. To clone a file, right-click on the editor window of an open file and select Clone View. Any text added or removed in one view is automatically updated in the other.

Zend Studio is a feature rich IDE with the added benefit of being cross platform. I hope you will download the trial and experience these features for yourself.

Peter Manis has been a PHP developer for four years and has worked with a variety of PHP IDEs.


  • PHP