Meet PHP Monitor, a companion for your multiple Homebrew PHP installations

September 10, 2019

At the company I work for, DIVE, we maintain a few legacy projects that use older versions of PHP. Every now and then, we have to make adjustments to these projects. This means that periodically, we need to be able to easily switch between multiple versions of PHP when working on different projects.

I have various versions of PHP installed on my Mac. I used to have a few scripts set up to switch between different PHP versions automatically (it would unlink other versions of PHP, set Valet’s preferred PHP version and restart web services) but I reworked those scripts into a small menu bar application.

This is what PHP Monitor looks like in your menu bar. It gives you easy access to all installed PHP versions and to the php.ini file for the active version of PHP.
This is what PHP Monitor looks like in your menu bar. It gives you easy access to all installed PHP versions and to the php.ini file for the active version of PHP.

So that’s how I came to build PHP Monitor, an open source app intended for this specific use case. It has three main features:

  • It shows the currently linked version of PHP in your menu bar.
  • It allows you to easily swap between PHP versions without having to run any additional commands.
  • It gives you easy access your PHP.ini file for the currently linked PHP version.


What is PHP Monitor?

PHP Monitor is a system utility that runs in the menu bar. Instead of showing an icon, it shows the currently active version of PHP. If you click on the menu item, it shows a list of installed PHP versions via Homebrew. You can then select the version of PHP you wish to use, and PHP Monitor will get to work.

The menu bar entry also gives you convenient access to your php.ini file. PHP Monitor is light on resources since it is a native app, and only executes a few console commands in the background, so installing newer or older versions of PHP shouldn’t be an issue.

Does PHP Monitor respect my privacy?

PHP Monitor does not send any data back to me, not even crash reports.

Do note that you may need to let PHP Monitor through your firewall if you use a program like Little Snitch — otherwise PHP Monitor won’t be able to execute all brew commands, as Valet sometimes checks if the php formula is installed. (I’m afraid I can’t change what the underlying commands do.)

In order to be transparent, I’ve also included a log so you can see what commands PHP Monitor is performing in the background as you’re running it. You can access this log via the menu bar item.

Also, since the app is open source, you are of course free to inspect how it all works.

Do you have any additional plans for the app?

Not at the moment.

I don’t have any immediate plans to add additional features, but I do intend to maintain the app to support future versions of PHP. If you have deprecated PHP installations those are supported too.

So, how can I use this?

The app’s source code is available on GitHub. However, you’ll have to build the app yourself, since I don’t distribute a signed build. For this, you’ll need the latest version of Xcode (10.3).

Do you offer support for this?

No, I do not offer support for the app. (If your PHP installation is broken, PHP Monitor may crash at launch.) I do welcome feedback via the repository.

Why are you sharing this?

This small tool has proven to be quite useful for me personally, so I figured sharing it might be helpful to some of you out there. I also wanted to make a small Mac app as a proof of concept for another idea that I’ve had.

Where can I find the source code?

For the source code and additional information, head over to the GitHub repository.

Tagged as: Programming