By Matt Butcher
os x
Configure iTerm2 To Act Like Visor
Submitted by matt on Mon, 2011-11-14 16:40
iTerm as VisoriTerm2 is a replacement for the built-in Mac terminal app. It provides many terminal features you may be used to from other systems (ahem, Linux), as well as some unique features and tools.
When it comes to OS X integration, iTerm2 has some amazing capabilities. You can even configure it to emulate Visor. Here I explain how to configure iTerm2 to slide down from the top of the screen like a Quake-style Visor. You can get an idea of what this looks like from the image on the left (click on it for a full-sized version). The borderless terminal window slides down from the top when focused, and then slides back up when not used. Never again will you need to hunt through your open windows looking for the terminal.
By mapping the visor to a hotkey, it becomes easy to quickly access a shell wherever you are without even taking your hands off the keyboard. And then, just as easily, the terminal can be dismissed. This article explains how to set up a visor-like terminal and then map a hotkey.
You can set up iTerm2 to do this in only three steps.
PHP Phar command line errors on OS X: Running 'php some.phar' generates '?????'
Submitted by matt on Wed, 2010-09-15 16:36When I tried to run pyrus.phar on Mac OSX recently, I had a strange experience. Executing php pyrus.phar generated the output ??? and then exited. With a little more testing, I discovered that all of my Phar packages, when from from the command line, generate "garbage" output (a series of question marks, usually) and then exit.
Quite a bit of digging later, I discovered an old bug report (recently re-opened) that documents the problem and suggests a solution. In a nutshell, the problem is that the Zend engine Unicode checker is enabled by default in at least some versions of PHP 5.3. My Apple-built PHP package (included in the Snow Leopard releases) has this problem, and I suspect that other builds do too.
While there is no solution yet, the workaround is as simple as setting the following ini directive:
detect_unicode = Off
While I'm not a huge fan of this workaround, it definitely works. I simply added it to my /etc/php.ini file, and now I can run pyrus and other Phar files.
Configuring MacGDBp for Debugging a Local Debian Virtual Machine
Submitted by matt on Tue, 2010-09-07 19:42In my current Drupal development environment, I run an entire Debian server stack (LAMP + Memcache + Varnish, etc) inside of a VirtualBox virtual machine. On those frustration-laden occasions when I need to fire up the debugger, I use MacGDBp to connect to the virtual machine. Here's how I configure them. (If you just want to configure MacGDBp for debugging with MAMP or OS X's Apache, you may want to read an earlier article, and then check out the updates for Snow Leopard.
Building Homebrew Packages
Submitted by matt on Fri, 2010-08-27 15:44
ttytterRecently I have been using Homebrew to install Open Source tools on my Mac. I find it to be a little more to my taste than MacPorts. But when I wanted to install TTYtter, a small Twitter command-line client, I discovered that Homebrew doesn't yet have a package for TTYtter.
After a quick chat with JohnAlbin, I decided to try building my own Homebrew formula for TTYtter. John has also successfully built a homebrew package or two. He re-assured me that learning the system wasn't going to require a huge investment of my time.
Fifteen minutes later, I committed my new script to the project, and it is now being considered for inclusion in Homebrew's repository. And almost all of the heavy lifting is done by the homebrew toolchain and git.
How easy was it? Well... I simply followed the directions, and moments later had this recipe:
Linux/UNIX/OS X: How to find and combine multiple files
Submitted by matt on Fri, 2010-04-16 14:26This explains how to use a UNIX-like command line (including Linux and OS X) and the find command to search through a subdirectory and find all of the files with a certain extension, and then combine those all into one file. Surprisingly, this isn't a difficult task. It can be accomplished with one command on the command line:
$ find ./src -name '*.txt' -exec cat '{}' \; > test.txtThe above looks through everything in the ./src directory (including all subdirectories) for any files with the .txt extension. Each file it finds, it adds to test.txt. So at the end of the command's run, all of the text files will be combined together into text.txt. You can use this strategy to easily combine lots of files into one.
Using find, it's easy to customize the command above to do all kinds of things with files. I gave a few examples in an earlier post about the UNIX find command.
OS X: Installing MongoDB and the PHP Mongo Driver
Submitted by matt on Sat, 2010-01-30 11:09MongoDB is a full-featured object database. Since it is fast, versatile, and schema-less, you can develop a very complex data storage layer without an ORM, and without any tedious coding. For this reason, I have been investigating MongoDB as a storage layer for PHP. Here's how to set up an environment on OS X Snow Leopard.
In this blog we'll do the following:
- Install MongoDB
- Add some initial data to MongoDB
- Install the PHP PECL driver for MongoDB
- Write a short PHP Script that uses MongoDB
- Shut down the MongoDB server
OS X: Using curl instead of wget
Submitted by matt on Fri, 2010-01-15 10:21OS X does not come with wget, a command-line tool for retrieving websites. For a while, I grumbled about this. I knew that curl was installed, but I hadn't ever used curl from the command line. But once I tried it out, I realized that for my needs, curl is just as good as wget... and I don't have to install anything extra to get it.
Here's how to use curl to fetch a remote URL:
$ curl -OL h ttp://spine-health.com/index.php
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 34646 0 34646 0 0 15314 0 --:--:-- 0:00:02 --:--:-- 17767This will download the remote file and store it locally in index.php. If you leave off the -O, it will write the file to standard output (your terminal, usually).
curl: Remote file name has no length!
Fetching from a URL's root can behave differently. If you perform the same command as above, but pointing to the base URL, you will get an error:
$ curl -OL h ttp://spine-health.com/ curl: Remote file name has no length! curl: try 'curl --help' or 'curl --manual' for more information
What's going on here? The error is not terribly informative on this point. The problem is that curl doesn't know where to write the output file. A better command here is something like this:
$ curl -L h ttp://spine-health.com/ > out.html
This time, the retrieved data will be written to the out.html file.
Like wget, curl has many options. You can read the man page for details, or you can get a quick summary with the usual curl --help command.
Phing: Fixing Output on OS X
Submitted by matt on Sat, 2009-12-26 17:18Using Phing on a Mac OS X console sometimes has a strange result: While the Phing script runs correctly, the console displays nothing. The reason for this is that the ANSI color codes used by some versions of Phing are not supported by OS X.
The solution is simple. Change the output logger.
$ phing -logger phing.listener.DefaultLogger ftest
This will use a non-colorized logger.
Installing XDebug 2 on Mac OS 10.6 Snow Leopard (with PHP 5.3)
Submitted by matt on Sun, 2009-11-22 16:16A while back, I wrote an extensive article on installing XDebug on OS X with MAMP. Now that I have Snow Leopard, I am making a new attempt at working with XDebug on OS X. This article discusses working with XDebug 2.0 or greater on Mac OS 10.6 with PHP 5.3, as packaged with OS X. Continue on for step-by-step instructions. (For more notes on upgrading a PHP dev environment for Snow Leopard, read this article.)
PHP Developer's Snow Leopard Upgrade Notes
Submitted by matt on Sat, 2009-11-21 19:20I'm upgrading to Snow Leopard, and I intend to switch from MAMP to the built-in PHP/Apache 2 configuration. As a PHP developer, there are several notable things that I wanted to track as I performed my upgrades. This article tracks those changes
PHP 5.3
My current OS 10.5 toolchain for PHP was this:
- PHP 5.2.6 (MAMP)
- Apache 2 (MAMP)
- MySQL 5 (MAMP)
- TextMate
- Git
- XDebug
- Several PEAR packages installed into MAMP's PHP 5, including PHPUnit, PhpDocumentor, Phing, and XDebug
One of the desired outcomes was to switch to the OS X version of PHP and Apache, which is tenable now that PHP is more robust (and now that I know how to use PEAR with the OS X version). It's also desirable because Snow Leopard is now running PHP 5.3. Here are my notes on the upgrade.
Update: Problems with PHPUnit and Phing.








