Web DevCenter
oreilly.comSafari Books Online.Conferences.
MySQL Conference and Expo April 14-17, 2008, Santa Clara, CA

Sponsored Developer Resources

Web Columns
Adobe GoLive
Essential JavaScript

Web Topics
All Articles
Scripting Languages

Atom 1.0 Feed RSS 1.0 Feed RSS 2.0 Feed

Learning Lab

PHP with Apple's Developer Tools
Pages: 1, 2


The table below shows some of Project Builder's text navigation key bindings. These keys may not be listed under the Edit menu, but they are supported by Cocoa's NSTextView, so they are available in almost every Cocoa application. Even a text input box on a Web form displayed in OmniWeb supports emacs-style navigation keys like Ctrl-A and Ctrl-E.

Alt-Left Arrow Move back one word
Alt-Right Arrow Move forward one word
Ctrl-A Move to beginning of line
Ctrl-E Move to end of line
Command-Up Arrow Move to top of file
Command-Down Arrow Move to end of file
Ctrl-H Delete previous character
Ctrl-D Delete next character
Alt-Delete Delete previous word

Related Reading

CVS Pocket Reference
By Gregor N. Purdy

The editor has a number of other noteworthy features. When you are editing a file, you get many levels of undo and redo, using the command-z and command-shift-z key combinations; it is even possible to undo changes back to a point prior to the time a file was last saved. When you need to see two files at once, command-" (command-shift-quote) will split an editor window in two, and command-' (command-quote) will later collapse the two editors back into one. To search for a string in the current editor, you can obtain a standard search-and-replace dialog box using command-f. Much more powerful, however, is the Project-wide Batch Find feature, which is available by selecting the Find tab above the editor panel or with the key combination command-shift-F. In the batch find panel you can search the entire project or even a customized subset of files for a simple text string or a complex regular expression.

As previously mentioned, one of Project Builder's best features is its integration with CVS and FileMerge. To see an example of this, open one of the files in the PEAR project, make some changes, and save them to disk. Then pull down the CVS menu and select Compare/Merge with latest revision. Project Builder will initiate a cvs diff command to compare the file to the version in the repository, and then display the differences in FileMerge. If you were authorized to commit changes to the repository, but needed to merge your changes with those of another developer, FileMerge would enable you to easily navigate through the changes using the up and down arrow keys, and then use the left and right arrow key to select one version or the other for the merged file.

What's in a Project

At this point, it's helpful to understand what Project Builder does behind the scenes. Close the PEAR window, quit Project Builder, and look in the directory where you downloaded the PEAR files. Project Builder has created one folder, called PHP-pear.pbproj, containing two files, project.pbxproj and username.pbxuser. The PHP-pear.pbproj directory is what Mac OS X refers to as a wrapper, a directory whose contents encapsulate a single document. The two pbxproj files inside it are both property lists: Unicode text files containing structured data. Many OS X property lists are XML files, but these two happen to be encoded in an older non-XML format. You can actually look inside these files using a few different tools. In the Terminal window where you originally fetched the CVS source, try this:

    cd PHP-pear.pbproj
    open -a TextEdit project.pbxproj
    open -a PropertyListEditor *.pbxuser

The TextEdit window shows the raw text of the project file (you could easily corrupt it, so be careful not to save any changes). The PropertyListEditor application allows you to navigate the tree structure of a property list or dump it into XML format. The contents of these files can be cryptic, but one thing is clear about them: the pbxproj file encodes the structure of the project itself (its files and groups ) while the pbxuser file contains your personal preferences and window coordinates. This distinction is significant if you want to share the project with other developers; you can commit the pbproj directory and pbxproj file into the CVS tree, but you should not commit the pbxuser file. When other developers retrieve the pbproj bundle from CVS and open it, Project Builder will silently create new pbxuser files for them.

Related Reading

Learning Cocoa with Objective-C
By James Duncan Davidson, Apple Computer, Inc.

Some Oddities

Project Builder was built primarily for Cocoa developers but has many features that are useful for Web developers. Using it outside its intended realm like this, though, one tends to find small items of annoyance here and there. (Some of them might be called "bugs," but then for the developers to address them might also be deemed "feature creep.") For instance, many Web projects contain plain HTML files, but when Project Builder sees a file with an .html extension it sometimes attempts to render the HTML, as it does with its Release Notes file, rather than let you edit the HTML source. However, if you create the HTML file in Project Builder itself (using File -- > New File), it seems that Project Builder will consistently open it for editing rather than rendering.

Another glitch for PHP developers concerns syntax coloring. In PHP, a string that is delimited by single quotes can contain literal double quote characters. The following is a legal line of code:

    $anchor = ' <a target="right" href="'; 

The unmatched double quote at the end of the string confuses Project Builder's syntax colorizer. You can put the colorizer back on track using a second double quote in a shell-style comment, like this:

    $anchor = '<a target="right" href="';  #"


Mac OS X is my environment of choice for developing PHP and Perl applications, primarily because Project Builder does a better job than any editor I know at making it easy to navigate a large collection of files. It helps me grasp the interdependencies in a big collection of source files, and I can always find the code I'm looking for quickly and easily. When running Apache and PHP on my Mac OS X machine, debugging becomes very easy. And when I decide to work on code in Java or C, I get to keep working in the same environment and take advantage of even more of Project Builder's features.

The best source of information on Project Builder is its online help. Apple also provides a Web page at http://developer.apple.com/tools/projectbuilder/, and there is a projectbuilder-users discussion list at http://lists.apple.com/.

John David Duncan works as a MySQL database administrator and Unix sysadmin, and as a freelance Web developer building data-driven sites with Apache and PHP.

Return to the Web Development DevCenter.