I am a big fan of TextMate and I am still learning to leverage its features, even after using it for over two years. I have started writing more “commands” to speed up my development process. I love that I can write commands in PHP that run locally on my Mac, and I still have access to all of the environment variables that TextMate passes such as the current line’s value or the document type and name.
The Problem
I recently upgraded to Snow Leopard, and as a result, upgraded to PHP 5.3 on my local development machine. I have been really impressed with the new features of 5.3, and I am happy it came packed with my OS X install. However, I noticed that a few of my commands had stopped functioning correctly.
I hadn’t had a chance to investigate the problem, but when I sat down to write a new command the other day, I figured it out. The $_ENV variable is an empty array on a default Snow Leopard install. When running PHP from the command line, this global variable holds all of the data about the environment PHP is running in. It’s also how TextMate injects it’s variables into the PHP script.