1
0
mirror of https://github.com/nicoverbruggen/phpmon.git synced 2025-08-07 03:50:08 +02:00
2021-01-29 19:57:13 +01:00
2021-01-09 13:38:32 +01:00
2021-01-09 13:46:45 +01:00
2021-01-29 19:57:13 +01:00
2021-01-29 19:57:13 +01:00
2019-07-15 17:19:51 +02:00
2021-01-09 13:46:45 +01:00
2021-01-06 17:29:24 +01:00

PHP Monitor

phpmon icon

PHP Monitor (or phpmon) is a lightweight macOS utility app that runs on your Mac and displays the active PHP version in your status bar.

phpmon screenshot (menu bar app)

It's also super convenient to switch between different versions of PHP. You'll even get notifications (only if you choose to opt-in, of course)!

phpmon screenshot (notification)

It also gives you quick access to various useful functionality (like accessing configuration files, restarting services, and more).

🖥 System requirements

PHP Monitor is a universal application that runs on Apple Silicon and Intel-based Macs.

  • macOS 10.15 Catalina or higher (works on macOS 11 Big Sur)
  • Homebrew is installed in /usr/local/homebrew or /opt/homebrew (the default)
  • The brew formula php has to be installed (which version is detected)
  • Laravel Valet 2.13 or higher

Please note that future versions of PHP will not work automatically, minor changes are usually required to add support for newer versions of PHP. You may need to update your Valet installation to keep everything working if a major version update of PHP has been released.

🚀 How to install

You can install via Homebrew, or may download the latest release.

To install via Homebrew, run:

brew tap nicoverbruggen/homebrew-cask
brew install --cask phpmon

To upgrade your existing installation, run:

brew upgrade phpmon

The app is signed and notarized, meaning all you have to do is approve its first launch.

👨‍💻 Why I built this

I wanted to be able to see at a glance which version of PHP was linked, and handle dealing with Laravel Valet in a simple app without having to deal with the terminal every time.

Initially, I had an Alfred workflow for this. But this does the job as well, while also showing me at all times which version of PHP is linked (which is the main benefit over e.g. an Alfred workflow).

🔧 Build instructions

build button in Xcode

If you'd like to build PHP Monitor yourself, you need:

  • Xcode (usually the latest version)
  • The contents of this repository

Once you have downloaded this repository, open PHP Monitor.xcodeproj, and you should be able to immediately build the app for your system by pressing Cmd-R. This will create a debug build. (If Xcode complains about code signing, you can turn it off.)

If you'd like to create a production build, choose "Any Mac" as the target and select Product > Archive.

🚜 How it works

Version detection

This utility runs php -r 'print phpversion()' in the background periodically (every 60 seconds).

Switching PHP versions

This utility will detect which PHP versions you have installed via Homebrew, and then allows you to switch between them.

This means:

  • You have at least the latest version of PHP installed (php)
  • You have installed Laravel Valet (which valet returns /usr/local/bin/valet)
  • You ran valet trust, which means Valet commands can be run without using sudo

The utility runs the following commands:

  • Unlink all detected PHP versions
  • Switch to whatever version of PHP php is at (this is done to ensure that Valet works, even when attempting to use PHP 5.6)
  • Stop all php-fpm service instances
  • Link the desired version of PHP
  • Start the correct php-fpm service for the desired PHP version

Want to know more?

If you want to know more about how this works, I recommend you check out the source code.

This app isn't very complicated after all. In the end, this just (conveniently) executes some shell commands.

🤬 Troubleshooting

If you are having issues, the first thing you should be doing is installing the latest version of PHP Monitor and Laravel Valet. This can resolve a variety of issues. To upgrade Valet, run composer global update. Don't forget to run valet install after upgrading.

PHP Monitor performs some integrity checks to ensure a good experience when using the app. You'll get a message telling you that PHP Monitor won't work correctly in the following scenarios:

  • The PHP binary is not located in /usr/local/bin/php (or /opt/homebrew/bin/php)
  • PHP is missing in /usr/local/opt (or /opt/homebrew/opt)
  • Laravel Valet is missing in /usr/local/bin/valet
  • Brew has not been added to sudoers in /private/etc/sudoers.d/brew
  • Valet has not been added to sudoers in /private/etc/sudoers.d/valet
  • Multiple PHP services are active (see more info below)

Follow instructions as specified in the alert in order to resolve any issues.

🏎 Quick Troubleshooting

PHP Monitor tells me php is not installed

Try installing again using brew install php.

This should resolve the issue! If that does not fix the issue, run brew link php --force. (Afterwards, you may need to restart your terminal to make sure the new linked version is detected.)

brew install php
brew link php --force

Valet sites won't load (502 Bad Gateway)

If you're visiting your .test domain, and you're getting a 502 (Bad Gateway) after switching to a different PHP version, you're dealing with a common issue.

This problem is usually resolved by upgrading Valet and running valet install again.

composer global update
valet install

📝 Additional Info

Please consult the additional file that contains more information. It may have answers to additional questions and more information to troubleshoot your problem.

Star me!

If this software has been useful to you, I ask that you please star the repository, so I know that the software is being used.

I did not include any tracking or analytics software, so if you encounter issues, let me know via an issue.

💵 Support me?

I develop this application in my spare time, after work. If you find the application useful and you have a bit of money to spare, feel free to send me a tip via PayPal.

Description
MIRROR. Lightweight, native Mac menu bar app that interacts with Laravel Valet. Helps you manage multiple PHP installations, locate config files and more.
https://phpmon.app Readme MIT 22 MiB
Languages
Swift 99.4%
HTML 0.5%