|
|
PHP with Apple's Developer Toolsby John David Duncan and Apple Developer Connection11/27/2002 Apple provides a powerful set of developer tools with Mac OS X. Originally developed by NeXT for programmers working with Objective-C, the tools have since evolved for use with a wide range of source languages, including Java, C++, and AppleScript. The Mac OS X developer tools package also includes the system header files and a C compiler, so it is an essential addition for anyone who wants a complete BSD Unix environment. At the heart of Mac OS X's developer tools is a full-featured text editor and IDE called Project Builder. Though normally used with applications built with the Carbon and Cocoa frameworks, Project Builder is an excellent tool for Web developers working in languages like PHP and Perl. Along with a standard Apple graphical interface, it also provides emacs-style key bindings that will be familiar to Unix users: keys combinations like Ctrl-A or Ctrl-E can be used to move the cursor to the beginning or end of a line. Its syntax colorizer recognizes comments and quoted strings in a variety of languages, making source code easier to read. It is tightly integrated with CVS, a software management system commonly used in the open source community. When dealing with a large number of files, Project Builder allows the developer to sort the files into groups for easier navigation. It offers multiple editor windows, split views, and a powerful multi-file search-and-replace facility that can search for either plain text strings or a regular expressions. Other tools bundled in the developer package include GNU Autoconf, both the BSD and GNU versions of make, and a useful application called FileMerge, which provides a graphical interface to the Unix diff utility. Project Builder uses FileMerge to display the differences between two versions of a file and allows developers to merge changes from the CVS repository into a new version. Some of the best features in the Developer Tools turn out to be of little use for Web scripting, though, such as the graphical Interface Builder and the excellent interaction between Project Builder and the gdb debugger.
I regularly use Project Builder and CVS to create and maintain complex PHP applications with dozens of source files. In this article, I'll illustrate some of the advantages of Project Builder and show some of the tricks I've learned. Obtaining the Developer ToolsIn the early 1990s, the developer release of NeXTSTEP sold for about $500 more than the standard user version. Today you can get the Developer Tools for little or no cost. The Developer Tools CD is included with most new Macs. Apple also gives the CD to new Apple Developer Connection members, and sells it for $20 from the ADC member's Web site at http://connect.apple.com/. If you have no CD, but a good Internet connection, you can choose to download the developer package from the ADC site; it's a hefty download, weighing in at 218MB. As of this writing, the December 2001 release of the Developer Tools was the latest available version. For people running Mac OS X version 10.1 or higher, the oldest usable version is the September 2001 release; the previous (May 2001) release runs only on the original OS X 10.0. Once you install the Developer Tools, Project Builder should be available under
When you open a single file this way, it appears in Project Builder's editor. Project Builder's online help is available using the Command-? combination. You will most often use Project Builder with groups of files, or projects, and in order to see most of its features in action, you have to create a project. Creating a ProjectIn order to have an example project to work with, you can retrieve a large Open Source PHP project from a CVS repository and then import its files into Project Builder. For this example I chose PEAR, a library of PHP classes available from http://pear.php.net, currently consisting of nearly 2,000 files. It takes a few shell commands to retrieve a working copy of PEAR. First you need to set the
If using tcsh, use this:
Then you can check out PEAR with the following commands.
The
At this point, Project Builder's main window should appear. On the left you'll see the File and Groups window; on the right, an editor panel displaying some release notes. Above the text you will see four tabs labeled Find, Build, Run, and Debug. Of these, only the Find tab is useful for web developers; the rest are used to compile and test applications written in C or Objective-C. Next, you can import all of the PEAR files into this new project with a single command.
The group relative reference style tells Project Builder to create a project structure that mimics the directory hierarchy, where each directory corresponds to a group. This is not the only way that Project Builder can use groups; a small C project might have one group for header files, one for C source files, and one for executables, even though all files are in a single directory. (For more documentation on creating and using groups see the Files topic in Project Builder's help.) Once you select Add, Project Builder will display all of the folders from the
|
|
|
|
|
||||||||