I’m a big fan of the Xcode IDE from Apple. Unfortunately, it is myopically focused on development for iOS and Mac OS X, using Objective-C. A long time ago, it was a lot more open. You could find a variety of plugins that would extend its functionality to include the projects you work with, outside of the Apple software ecosystem. But for the past several years Apple has made it difficult to extend the IDE beyond their intended purposes. I’m mainly a backend PHP developer, but I have been a long-time Mac user. This puts me in the position of having second-rate tools for the biggest reason I use my computer. Yes, there are IDEs for Mac OS X that focus on PHP, but they’re all cross-platform and written in Java, which is, itself, a second class citizen on the Mac platform.
I’ve suffered through using Netbeans, Eclipse, and PHPStorm for years, all the while yearning for a grown-up IDE like Xcode to do my job. No longer! With Xcode 4, Apple introduced CodeSnippets that allow a user to not only save commonly used code snippets to an easily accessible palette, but we can tokenize the snippets and define the prefix text to which Xcode’s autocomplete feature will respond. Type “fore…” and if you have a snippet called “foreach”, Xcode will offer up the helpful autocomplete list with your snippet. Hit tab or enter and the snippet will be inserted at the cursor. Hit tab again and you’ll be guided through the snippet’s tokens, one by one, allowing you to fill in the blanks.
With this in mind, I went to work creating over 5,000 snippets to cover the entirety of the PHP language. See my github repo here: https://github.com/tonyjohnston/PHP-Xcode-Autocomplete Now I have native-like autocomplete for Xcode. I start typing “str” and here’s what I see:
Each of those blue rectangular ovals is a tabable token, just waiting for you to enter your specifics, just like Xcode’s support for Objective-C. It’s a huge advancement in the arena of Mac PHP IDEs. It took me about 6 hours to put this whole thing together so I’m sure that it can get better. Feel free to fork my GitHub repo for PHP Xcode Support and help make PHP a first class citizen on the only great IDE for the Mac.