Code Monkey home page Code Monkey logo

phpmon's Introduction

Note If this software has been useful to you, I ask that you please star the repository, that way I know that the software is being used. Also, please consider sponsoring to support the project, as this is something I make in my free time. Thank you! ⭐️

PHP Monitor Logo

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. It's tightly integrated with Laravel Valet, so you need to have it set up if you want to use all of the functionality of the app (consult the FAQ below with info about how to set up your environment).

phpmon screenshot (menu bar app)

Screenshot: Showing the key functionality of PHP Monitor.

It's 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)

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

You can also add new domains as links, isolate sites, manage various services, and perform First Aid to fix all kinds of common PHP link issues.

πŸ–₯ System requirements

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

  • Your user account can administer your computer (required for some functionality, e.g. certificate generation)
  • macOS 12.4 or later (Monterey, Ventura and Sonoma are supported)
  • Homebrew is installed in the default location (/usr/local/homebrew or /opt/homebrew)
  • Homebrew php formula is installed
  • Optional but recommended: Laravel Valet

Starting with PHP Monitor 6.0, you do not need to have Laravel Valet installed for PHP Monitor to work. To get access to all features of PHP Monitor however, installing Valet is recommended.

For more information, please see SECURITY.md to find out which version of the app is currently supported.

πŸš€ How to install

Again, if you want to have access to all features of PHP Monitor, I recommend installing Laravel Valet first:

composer global require laravel/valet
valet install
valet trust

Currently, PHP Monitor is compatible with Laravel Valet v2, v3 and v4. Each of these versions of Valet support slightly different PHP versions, which is why legacy versions remain supported. Please note that some features are not available in older versions of Valet, like site isolation.

Manual installation (recommended, first time only)

Once that's done, you can download the latest release, unzip it and place it in /Applications.

Installation via Homebrew

Prior to version 5.8, this was the recommended way of installing PHP Monitor.

If you prefer to install the app via Homebrew, you can also run the following:

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

⬆️ How to update

The recommended method of updating the app to the latest version is to use the built-in updater.

If you have a very slow internet connection, the updater may report that the download has timed out. In that case, you may wish to manually update by downloading the latest release and placing the app in /Applications.

(You may also use Homebrew to update PHP Monitor, but this will require you to approve the app every time an update is installed. If you use the built-in updater, this won't be necessary.)

⚑️ Launchers (Alfred, Raycast)

If you would like to integrate with your launcher of choice, you can also download an Alfred workflow or Raycast extension that works with PHP Monitor.

The app must be running in the background for these to work, and the Allow third-party integrations checkbox must be enabled in Preferences (it is by default).

πŸ”‘ Is the app signed & notarized?

Yes, the app is signed and notarized, meaning all you have to do is approve its first launch (or whenever it updates).

πŸ‘¨β€πŸ’» Why build 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 it has now been replaced with this utility, which also does a good job at displaying additional information at a glance, like the current PHP version, memory limits, and more.

🐘 Why not use Laravel Herd?

If you don't need to customize your local PHP setup and just want an easy and ready-to-go environment to start coding, Laravel Herd is probably more than sufficient for many use cases.

If you need more customization and flexibility I encourage you to consider PHP Monitor in combination with Laravel Valet or some other solution like Docker (with Laravel Sail, for example).

🀬 The app won't start?!

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 a variety of scenarios.

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

(If the app crashes at launch without showing you any of these messages, you might have a non-standard Homebrew and Valet setup. Those are not supported.)

πŸ™‹β€β™‚οΈ FAQ & 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.

If you're still having issues, here's a few common questions & answers, as well as issues and solutions:

Which versions of PHP are supported?

All stable and supported PHP versions are also supported by PHP Monitor. However, depending on which version of Valet you have installed, which versions of PHP that are made available for switching purposes may differ.

Note If you have versions of PHP installed that can be detected by PHP Monitor but is not supported by the currently active version of Valet, you will be alerted by an item in the menu with an exclamation mark emoji. (⚠️)

Backports that are installable via PHP Monitor's PHP Version Manager functionality are subject to availability via this tap.

PHP extensions that are installable via PHP Monitor's PHP Extension Manager functionality are subject to availability via this tap.

For maximum compatibility with older PHP versions, you may wish to keep using Valet 2 or 3. For more information, please see SECURITY.md to find out which versions of PHP are supported with different versions of Valet.

How do I install additional versions of PHP, including legacy versions?

Assuming you have installed the php formula, the latest stable version of PHP is installed. At the time of writing, this is PHP 8.3.

You can install other supported versions of PHP via PHP Monitor's PHP Version Manager. (You can manually install or upgrade PHP versions too, but this is not recommended.)

Please keep in mind that installing or updating PHP versions, even when done via PHP Monitor's PHP Version Manager, may cause other required formula dependencies (required software needed to keep those PHP versions functional) to be upgraded. It might not be very transparent when this happens, but this is likely the cause if installing a PHP version takes longer than expected: usually other dependencies are also being installed.

Additionally, upgrading one specific version of PHP may also cause other installed versions of PHP to also be updated in one go, if the dependencies for that one version also apply to the other (newer) version(s) of PHP. It's a bit tricky to manage PHP versions via Homebrew, and even PHP Monitor may encounter some difficulties.

If you encounter a strange scenario or a malfunction, please open an issue on the issue tracker and get in touch. I'd like to keep enhancing this process to make it as foolproof as possible.

Note: Using PHP Monitor when managing PHP versions may cause temporary alias conflicts while the core tap alias and the tap's alias refer to a different version of PHP, but this is generally speaking a minor inconvenience, since this normally only applies when a new PHP version releases.

I want PHP Monitor to start up when I boot my Mac!

If you are running macOS Ventura or newer, there's an option in the Settings menu that you can select: "Start PHP Monitor at login".

If you are on an older version of macOS, you can do this by dragging PHP Monitor.app into the Login Items section in System Preferences > Users & Groups for your account.

Super convenient!

What features are unavailable in Standalone Mode?

The services manager is disabled, and all other obvious Laravel Valet integrations (configuration finder, domains list, Fix My Valet) are also disabled.

(Most other features remain available.)

I want to set up PHP Monitor from scratch! I don't have Homebrew installed either, where do I begin?

If you want to set up your computer for the very first time with PHP Monitor, here's how I do it.

I have also created a video tutorial which may be easier to follow. If you just want the terminal commands, keep reading.

Install Homebrew first. Follow the instructions there first!

Then, you'll need to set up your PATH.

nano .zshrc

Make sure the following line is not in the comments:

# on an Intel Mac
export PATH=$HOME/bin:/usr/local/bin:$PATH

If you're on an Apple Silicon-based Mac, you'll need to add:

# on an M1 Mac
export PATH=$HOME/bin:/opt/homebrew/bin:$PATH

and add the following to your .zshrc file, but add this BEFORE the homebrew PATH additions:

export PATH=$HOME/bin:~/.composer/vendor/bin:$PATH

If you're adding composer and Homebrew binaries, ensure that Homebrew binaries are preferred by adding these to the path last. On my system, that looks like this:

export PATH=$HOME/bin:/usr/local/bin:$PATH
export PATH=$HOME/bin:~/.composer/vendor/bin:$PATH
export PATH=$HOME/bin:/opt/homebrew/bin:$PATH

If you are not on Apple Silicon, you should remove the third line.

Install the php and composer formulae:

brew install php composer

Make sure PHP is linked correctly:

which php

should return: /usr/local/bin/php (or /opt/homebrew/bin/php if you are on Apple Silicon)

If you don't need Laravel Valet, you can stop here. PHP Monitor will work like this in Standalone Mode.

If you'd like to have Valet as well, continue and install Valet with Composer, like this.

composer global require laravel/valet

For optimal results, you should lock your PHP platform for global dependencies to the oldest version of PHP you intend to run. If that version is PHP 7.0, your ~/.composer/composer.json file could look like this (please adjust the version accordingly!):

{
    "require": {
        "laravel/valet": "^3.0",
    },
    "config": {
        "platform": {
            "php": "7.0"
        }
    }
}

Run composer global update again. This ensures that when you switch to a different global PHP version, Valet won't break. If it does, PHP Monitor will let you know what you can do about this.

Then, install Valet:

valet install

This should install dnsmasq and set up Valet. Great, almost there!

valet trust

Finally, run PHP Monitor. Since the app is notarized and signed with a developer ID, it should work. You will need to approve the initial launch of the app, but you should be ready to go now.

How frequently does PHP Monitor check for updates?

PHP Monitor will check if an update is available every time you start the app.

You can disable this behaviour by going to Preferences (via the PHP Monitor icon in the menu bar) and unchecking "Automatically check for updates". (You can always check for updates manually.)

I have PHP Monitor installed, and it works. I want to upgrade my PHP installations to the latest version, what's the best way to do this?

The easiest way is to simply use the built-in PHP Version Manager, which will allow you to upgrade your PHP versions with one click.

If you want to do this manually, you can follow the instructions below.

It's easy to make a mistake here, and end up with an unlinked version of PHP or have versions missing from PHP Monitor.

Here's what I usually do:

  • Open PHP Monitor and select First Aid & Services > Restore Homebrew Permissions.
  • Close PHP Monitor after the pop-up tells you the permissions were restored.
  • Run brew update-reset
  • Run brew upgrade

If after this, any PHP versions are missing in PHP Monitor, please run the following for the versions that are missing:

  • Run brew uninstall [email protected] (where x.x is the version)
  • Run brew cleanup (if you get any permission issues you may need to manually clean up the folder)
  • Run brew install [email protected] (where x.x is the version)

You may still need to run brew link php after upgrading, too.

That's it. Now start up PHP Monitor again and you should be golden!

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. I'm getting a 502 Bad Gateway error!

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

If you are seeing a 502 (Bad Gateway) error after about 30 seconds or so, your request is likely timing out. You may need to solve a performance issue with your own code.

PHP Monitor tells me my installation is broken, but I don't see why!

PHP Monitor tells you that a PHP installation is broken, if the configuration is causing warnings or errors when determining the version number.

Since PHP Monitor changes the linked version via Homebrew, both Valet and your terminal (CLI) should use the new PHP version.

However, this might not be the case on your system. You might have a specific version of PHP linked if that is not the case. In that case, you may need to change your .bashrc or .zshrc file where the PATH is set (depending on the terminal you use).

You can find out which version of PHP is being used by running which php.

You can find out what exactly is causing the issue by running a command. On Intel, you can run (replace 7.4 with the version that is broken):

/usr/local/opt/[email protected]/bin/php -r "print phpversion();"

On Apple Silicon, you can run (replace 7.4 with the version that is broken):

/opt/homebrew/opt/[email protected]/bin/php -r "print phpversion();"

You should see an error or a warning here in the output.

Usually this is a duplicate extension declaration causing issues, or an extension that couldn't be loaded. You'll have to solve that issue yourself (usually by removing the offending extension or reinstalling).

The option to isolate a site is disabled! What's going on?

Make sure you have at least Valet 3.0 installed, since support for isolation was added in this version of Valet. (Please note that this version of Valet drops support for PHP 5.6.)

One of the limits (memory limit, max POST size, max upload size) shows an exclamation mark!

The value you provided in your .ini file is invalid. If that is the case, PHP will attempt to parse your value as bytes, which is usually unintended. (1GB will resolve to merely a few bytes, and all of your applications will run out of memory!)

You must a provide a value like so: 1024K, 256M, 1G. Alternatively, -1 is also allowed, or just an integer (which will result in N amount of bytes being the limit).

Example: Trying to use 1GB as the memory limit, for example, will result in this exclamation mark. The correct way to set a 1GB limit is by using 1G as the value. (Note: The displayed value will append B for clarity, so if you set 1G, the value reported by PHP Monitor will be 1 GB.)

(If you are using Valet, you can adjust these limits in the .conf.d/php-memory-limits.ini file. Otherwise, you may need to adjust php.ini.)

One of my commented out extensions is not being detected...

The app searches in the relevant .ini files for a specific pattern. For regular extensions:

  • extension="*.so"
  • ; extension="*.so"

For Zend extensions:

  • zend_extension="*.so"
  • ; zend_extension="*.so"

The * is a wildcard and the name of the extension. If you've commented out the extension, make sure you've commented it out with a semicolon (;) and a single space after the semicolon for PHP Monitor to detect it.

Since v3.4 all of the loaded .ini files are sourced to determine which extensions are enabled.

I've got two Homebrew installations on my Apple Silicon Mac, can I choose which installation to use with PHP Monitor?

If you are using PHP Monitor on an Intel machine or on an Apple Silicon machine with Rosetta enabled, PHP Monitor expects the main Homebrew binary in /usr/local/bin/brew.

If you are using PHP Monitor on Apple Silicon without Rosetta, PHP Monitor expects the main Homebrew binary in /opt/homebrew/bin/brew.

If there's an issue here, you'll get an alert at launch.

Make sure that the version of Homebrew that you are running normally is the same as the one that PHP Monitor expects. If you are on M1 hardware for example, but still using Rosetta for Homebrew, you'll need to run PHP Monitor under Rosetta as well.

PHP Monitor is a universal app and supports both architectures, so find out here how to enable Rosetta with PHP Monitor.

Why is the app doing network requests?

The app will automatically check for updates, which is the most likely culprit.

This happens at launch (unless disabled), and the app directly checks the Caskfile hosted on GitHub. This data is not, and will not be used for analytics (and, as far as I can tell, cannot).

I also can't prevent brew from doing things via the network when PHP Monitor uses the binary.

The app includes an Internet Access Policy file, so if you're using something like Little Snitch there should be a description why these calls occur.

How do I various presets to show up?

You must set these presets up in a JSON file, located in ~/.config/phpmon/config.json.

You must have set up at least one valid preset for this presets to work in PHP Monitor.

Here's an example of a working preset:

{
    "scan_apps": [],
    "services": [],
    "presets": [
        {
            "name": "Legacy Project",
            "php": "8.0",
            "extensions": {
                "xdebug": false
            },
            "configuration": {
                "memory_limit": "128M",
                "upload_max_filesize": "128M",
                "post_max_size": "128M"
            }
        }
    ],
    "export": {}
}

You can omit the php key in the preset if you do not wish for the preset to switch to a given PHP version.

Warning You must restart PHP Monitor for these changes to be detected.

How do I ensure additional Homebrew services are shown in the app?

Info Homebrew services aren't displayed if you are using Valet in Standalone Mode.

You must set these services up in a JSON file, located in ~/.config/phpmon/config.json.

You can specify custom services in the configuration file for Homebrew services that run as your own user (not root).

Info If your service must run as root, it cannot currently be added to PHP Monitor.

You can find out which services are available by running brew services list.

Here's an example where we add the mailhog and mysql services to PHP Monitor:

{
    "scan_apps": [],
    "services": ["mailhog", "mysql"],
    "presets": [],
    "export": {}
}

Warning You must restart PHP Monitor for these changes to be detected.

How do I set custom environment variables?

You must configure these custom environment variables up in a JSON file, located in ~/.config/phpmon/config.json.

PHP Monitor uses a default Shell environment, with no custom environment variables. You need to set custom environment variables manually. These are then used for e.g. Composer.

Here's an example of a working COMPOSER_HOME environment variable which is respected:

{
    "scan_apps": [],
    "services": [],
    "presets": [],
    "export": {
        "COMPOSER_HOME": "/absolute/path/to/composer/folder"
    }
}

Warning You must restart PHP Monitor for these changes to be detected.

How do I get various applications to show up in the domain list's right-click menu?

When you select and right-click on a domain, you can open these directories with various applications. This can help speed up your workflow. However, for these apps to show up, they must be detected first.

The supported apps are: PhpStorm, Visual Studio Code, Sublime Text, Sublime Merge, iTerm.

All of these apps should just be detected correctly, no matter their location on your system. If you can open it using open -a "appname", the app should be detected and work. If you have renamed the app, there might be an issue getting it detected.

To see which files are checked to determine availability, see this file.

You can add your own apps by creating and editing a ~/.config/phpmon/config.json file, and make sure the scan_apps key is set:

{
    "scan_apps": ["Xcode", "Kraken"]
}

You can put as many apps as you'd like in the scan_apps array, and PHP Monitor will check for the existence of these apps. You do not need to set the full path, just the name of the app should work. Not all apps support opening a folder, though, so your success might vary.

Warning You must restart PHP Monitor for these changes to be detected.

How can the app integrate with third party tools, like Alfred or Raycast?

PHP Monitor supports third party app integrations by default, and this feature is enabled in Preferences unless you disable it.

You can grab the official Alfred workflow or Raycast extension.

If you'd like to integrate something yourself, all you need to to is use the phpmon:// protocol and ensure that third party app integrations are enabled in Preferences (in PHP Monitor).

Using app callbacks, macOS and PHP Monitor allow for the following to be called:

  • phpmon://list
  • phpmon://services/stop
  • phpmon://services/restart/all
  • phpmon://services/restart/nginx
  • phpmon://services/restart/php
  • phpmon://services/restart/dnsmasq
  • phpmon://locate/config
  • phpmon://locate/composer
  • phpmon://locate/valet
  • phpmon://phpinfo
  • phpmon://switch/php/{version}
How does the app know what PHP version is required for my app?

The composer.json file in the root of the folder (if it exists) is scanned and interpreted.

If the version is set in platform, it takes precendence. If the version is not set in platform but it is in require (most common) then that version is used.

What do the checkmarks next to the PHP version mean in the site list?

You'll see a checkmark next to the version number if the currently enabled PHP version is compatible with the version required to run the site.

This is determined by evaluating the PHP requirement constraint (e.g. ^8.0, ~8.0 or a specific version: 8.0).

Why can't I see the driver type any more? It says "Project Type" now.

PHP Monitor currently checks your composer.json file to try to figure out what project you are running.

This approach is a lot faster than asking for a driver when you have many sites linked, but is slightly less reliable since the framework or type of project inferred via composer.json might not be 100% accurate.

You can always still ask Valet using the command line, should it be necessary. In my experience fetching the drivers slowed down the app unnecessarily.

After running PHP Monitor, Homebrew sometimes has issues with `brew upgrade` or `brew cleanup`!

You can now use First Aid & Services > Restore Homebrew Permissions to (temporarily) resolve this issue and allow for a clean and painless brew upgrade or brew cleanup process.

If you would like to know more, consult this issue for more information about why this is needed.

The app has crashed!

Please get in touch and open an issue. PHP Monitor shouldn't crash... (unless you are actually removing PHP while the app is running, that’s considered normal behaviour!)

If you would like to report a crash, please include the associated log files so I can find out what exactly went wrong.

To find the logs, take a look in ~/Library/Logs/DiagnosticReports (in Finder) and see if there's any (log) files that start with "PHP Monitor".

Additionally, you can help me figure out even more information by sending me your verbose log for your latest session of PHP Monitor. Logging is disabled by default.

You can start extra verbose logging by running: touch ~/.config/phpmon/verbose and restarting PHP Monitor. You can find the latest log in: ~/.config/phpmon/last_session.log. Please attach it to the relevant bug report.

πŸ“ Having another issue?

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

πŸ’΅ Support me?

PHP Monitor is available entirely free of charge, but if you can afford it a donation helps keep the project alive and the app maintained.

You can find a sponsor link at the top of this repo or you could click the link here to be taken to my sponsorship page.

Donations really help with the Apple Developer Program cost, and keep me motivated to keep working on PHP Monitor outside of work hours (I do have a day job!).

😎 Acknowledgements

Special thanks go out to:

  • Everyone supporting me via GitHub Sponsors
  • Everyone who has donated via my sponsor page
  • The Homebrew team & Valet maintainers
  • Various folks who reached out when PHP Monitor was still very much a small app with a handful of stars or so
  • Everyone who has left feedback and reported bugs
  • Everyone in the Laravel community who shared the app, especially on Twitter

Thank you very much for your contributions, kind words and support.

🚜 How it works

Loading info about PHP in the background

This app runs php-config --version in the background periodically, usually whenever your Homebrew configuration is modified. A filesystem watcher is used to determine if anything changes in your Homebrew's bin directory.

PHP Monitor also checks your .ini files for extensions and loads more information about your limits (memory limit, POST limit, upload limit). See also the section on Config change detection below.

Switching PHP versions

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

The switcher will disable all PHP-FPM services not belonging to the version you wish to use, and link the desired version of PHP. Then, it'll restart your desired PHP version's FPM process. This all happens in parallel, so this should be a bit faster than Valet’s switcher.

If you're using Valet 3 or newer, versions of PHP-FPM required to keep isolated sites up and running will also be started or stopped as needed.

Config change detection

PHP Monitor watches your filesystem in the relevant conf.d directory for the currently linked PHP version.

Whenever an .ini file is modified, PHP Monitor will attempt to reload the current information about the active PHP installation.

If an extension or other process writes to a single file a bunch of times in a short span of time (< 1 sec), PHP Monitor will only reload the active configuration information after a while (with a slight delay).

Site detection

  1. Location of your sites: PHP Monitor uses the Valet configuration file to determine which folders to look into. Each folder is scanned and then PHP Monitor will validate if a composer.json file exists to determine the desired PHP version.
  2. Sites secured or not secured: Whether the directory has been secured is determined by checking if a matching certificate exists under Valet's Certificates directory for that site name.
  3. Project type: PHP Monitor checks your composer.json file for "notable dependencies". If you have laravel/framework in your require, there's a good chance the project type is Laravel, after all.

Note If you have linked a folder in Documents, Desktop or Downloads you might need to grant PHP Monitor access to those directories for PHP Monitor to work correctly.

Want to know more?

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

I have done my best to annotate as much as humanly possible, and have avoided using an overly complicated architecture to keep the code as easy to maintain as possible. The code isn't perfect by a long shot (lots of cleanup can still happen!) but the application works well.

I also have a few tests for key parts of the application that I found needed to be tested. In the future, I would like to add even more tests for some of the UI stuff, but for now the tests are more unit tests than feature tests.

For more detailed information for developers, please see the documentation file for developers.

phpmon's People

Contributors

jasonvarga avatar nicoverbruggen avatar tadhgboyle avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

phpmon's Issues

Extensions in other ini files not detected

I've got xdebug in a separate ini file, and phpmon doesn't appear to detect that.

Output of php --ini:

Configuration File (php.ini) Path: /opt/homebrew/etc/php/7.4
Loaded Configuration File:         /opt/homebrew/etc/php/7.4/php.ini
Scan for additional .ini files in: /opt/homebrew/etc/php/7.4/conf.d
Additional .ini files parsed:      /opt/homebrew/etc/php/7.4/conf.d/error_log.ini,
/opt/homebrew/etc/php/7.4/conf.d/ext-opcache.ini,
/opt/homebrew/etc/php/7.4/conf.d/php-memory-limits.ini,
/opt/homebrew/etc/php/7.4/conf.d/xdebug.ini

Contents of xdebug.ini:

zend_extension="xdebug.so"
[xdebug]
xdebug.mode = develop,debug
xdebug.start_with_request = yes
xdebug.client_port = 9000

Could phpmon use these additional ini files when handling extensions as well?

Detect what version of PHP corresponds to `php`

Not everyone who uses PHP via Homebrew immediately upgrades to the latest version of PHP.

While this is encouraged, there's a chance that the user still needs to upgrade. To determine which version is currently in use, I can use:

brew info php --json

This tells us via $0.aliases.$0 which alias corresponds to PHP; this could run at launch.

Send notifications when switching is complete

Since switching takes some time (so does resetting the PHP services) it might be cool to have a setting that you can toggle that makes it so that a notification is shown whenever the PHP version switch has completed.

I think the default should be OFF, though.

The user can control whether they want to see notifications via System Preferences > Notifications.

Duplicate listings of PHP

I suspect this is more an issue with my setup than PHPMON itself, but I'm seeing duplicate options for php in the listing which is a bit unexpected.

Changing PHP version dims out both options for that version as shown here:
Screenshot 2021-03-31 at 15 07 07
Screenshot 2021-03-31 at 15 06 11

Changing version in phpmon does not change version in iTerm

Hi!

I just installed phpmon, and it looks great! However, I have issues changing PHP versions. If I switch between PHP 8.0, 7.4 and 7.3 it reflects in the browser, but in iTerm the PHP is stuck on 7.3.27.

I have tried Force load latest PHP version, but no change in iTerm.

Running which php shows: /usr/local/opt/[email protected]/bin/php

My path: $HOME/bin:/usr/local/bin:~/.composer/vendor/bin:$PATH

I have tried restarting my computer, but the problem is still there.

When I run brew services list I get the following output:
php error root /Library/LaunchDaemons/homebrew.mxcl.php.plist
[email protected] stopped
[email protected] stopped

In Activity Monitor I see that I have three php-fpm processes running, one as root and two as my username.

Has anyone experienced this issue and resolved it?

Truck icon

Could you add an option to display the truck icon all the time?

For whatever reason, I find the PHP version as the icon to be distracting. If I need to know which one I'm on, it's only a click away.

I understand people like it though, thats why an option would be nice.

sudo: no tty present and no askpass program specified

No check occurs if valet trust was ran, so the commands may end up failing with the following log:

sudo: no tty present and no askpass program specified

An extra check should be added to verify if the user ran valet trust. (If this is possible.)

opcache not detected

At the bottom of my php.ini I have enabled the two extensions opcache and xdebug

[opcache]
zend_extension="/usr/local/opt/php/lib/php/20200930/opcache.so"

[xdebug]
zend_extension="xdebug.so"

phpinfo() says both of them are loaded
Bildschirmfoto 2021-03-31 um 14 45 04

but PHP Monitor only shows me xdebug
Bildschirmfoto 2021-03-31 um 14 44 50

I don't know if this is a bug or if opcache is a special case?

Configurable global hotkey

This feature is now implemented. This is interesting territory for me, because I've never needed to implement something as far-reaching as a global hotkey before. Remember, setting a hotkey here might disable it in other apps.

Avoid root:admin ownership of php binaries

Due to PHP Monitor running sudo brew services start php, Homebrew takes ownership of the PHP binaries, thus requiring you to remove the current PHP version manually when running brew upgrade.

I just stumbled upon this again today when I was updating my brew packages...

I'm not sure why Homebrew takes ownership of these binaries (because sudo, I guess?), but if I try running the PHP service as a regular user, nginx does not seem to pick up on php-fpm, so I have no ideal solution for this.

I will try to investigate this on a clean installation and see if I can't figure out a solution.

If I can get this sorted, I'll include a "migration" flow that you'll be alerted of at launch (recommending going from sudo'd services to regular user service).

App does not start if Homebrew is installed in /opt/homebrew (pre-release build available!)

PHP Monitor complains about the missing binaries.

  • PHP binary is located in: /opt/homebrew/bin/php

Current workaround: use Rosetta or the pre-release build below

Whenever I have time, I will verify that this does not break existing installations on Intel, and then release this version.

If you need a fix ASAP, please see the pre-release build here: https://github.com/nicoverbruggen/phpmon/releases/tag/v2.6-prerelease (notarized)

Apple Silicon support

As far as I can tell, PHP Monitor works just fine on macOS Big Sur (on Intel Macs).

I do not have access to a Developer Transition Kit, so I cannot test on arm64, nor do I plan to release an Universal 2 binary before consumer Macs are available (and we know the status of Homebrew, PHP, Valet...).

The documentation should reflect this information.

  • Update documentation to include macOS Big Sur support
  • Update README to include new icon + new screenshots
  • Make a Universal build with Xcode 12.2

v3.4 beta testers wanted!

I'm currently working on the next point update for PHP Monitor, but I need some valuable feedback from you guys. It would be really handy if you guys would please try out this new build:

v3.4, beta 1

  • Global hotkey added: You can now go to Preferences and set up a global hotkey to trigger PHP Monitor
  • More hotkeys: Each item that triggers an action should now have a shortcut; extensions are limited to the first nine (extensions 10 and onwards don't have a shortcut)
  • Scan all .ini files: Often requested, and finally here. All your .ini files are now scanned for extensions.

Screenshot 2021-04-07 at 17 05 59

Known issues

  • Some shortcuts won't work if they're set in System Preferences
  • You cannot press Esc to abort choosing a shortcut
  • Closing the window does not abort choosing a shortcut

Download

You must download the build here and replace the existing build:
phpmon-3.4-beta1.zip

Oh, and keep all beta feedback in this thread, please! :)

Add install instructions to README

If you want to set up your computer for the very first time, here's how I do it:

Install Homebrew first.

Install PHP, composer, add to path:

brew install php
brew install composer
nano .zshrc

Make sure the following line is not in the comments:

export PATH=$HOME/bin:/usr/local/bin:$PATH

and add the following to your .zshrc:

export PATH=$HOME/bin:~/.composer/vendor/bin:$PATH

Make sure PHP is linked correctly:

which php

should return: /usr/local/bin/php

composer global require laravel/valet
valet install

This should install dnsmasq and set up Valet. Great, almost there!

valet trust

Finally, run PHP Monitor (you may need to option + right-click and select Open to avoid issues with macOS Gatekeeper). Yay!

Handle socket file mitigation

I don't know if this is actually still an issue with more recent versions of Valet but I see people discussing this every now and then so perhaps it's a good idea to erase the socket file (~/.config/valet/valet.sock) if it still exists prior to force linking a new PHP version.

At the same time, I feel like this might not be an issue? Worth investigating.

The relevant code to check if the Valet socket exists, and how to remove it:

if [ -S ~/.config/valet/valet.sock ]; then rm ~/.config/valet/valet.sock; fi

or alternatively:

test -S ~/.config/valet/valet.sock && echo "Socket file exists."

Bump base SDK version to Catalina

Since I can't guarantee functionality on older versions of macOS, the app should just say that it is not supported on an older version of macOS. This is done by bumping the base SDK version to 10.15.

(If #21 can be resolved, that would be even better.)

Unable to start phpMon while all is ok

At the start of phpMon, here are all the errors I got, in the same screenshot it shows that all is correct...
Capture d’écran 2021-07-30 aΜ€ 13 15 46
Capture d’écran 2021-07-30 aΜ€ 13 14 52

Do you have any idea how to fix this?

Thanks
Christophe

Having trouble with [email protected]

Curently, I've got 8.0, 7.4 and 7.1 installed. PHP Monitor sees them all. I can switch and use 8.0 and 7.1 just fine, but trying to switch to 7.4 causes PHP Minitor to show the "πŸ’© broken" message in the status bar (although checking PHP info tells me it uses 7.4).

I'm not really sure how to help you debug this, but if you tell me if there's any log that could be of importance, or anything, do tell and I'll help ! :)

Links list

Hi Nico, thanks for the hard work on this app, Im just starting and it would be great if there was a list of all the available links in a submenu (like restart specific service), on click this would open the default browser with the link.

Just an idea, thanks

VS Code Terminal using default Mac PHP

You guys are AWESOME !!!

I love working with the latest version of PHP, but I have one project that needs to stay fixed on PHP 7.4 (for now), and using PHP Mon is just SO great with that - Thank you SO much for a great App!

I work from a Mac with Apple M1 and everything run great there, with one little exception that may just be a setup I need to change and likely not related to PHP Mon.

When I open a terminal within VS Code it runs my default shell zsh but for some reason doesn't locate the PHP version set in PHP mon and always reverts back to default installed with the mac. (Screenshot attached shows PHP mon working fine in regular terminal, but not in VSCode terminal)

I can manually set a search path in ~/.zshrc but that will lock it down to one version. Is there something I'm missing in my ~/.zshrc or VS Code setup?

Thank SO much for your help and this great app'

Screen Shot 2021-09-05 at 9 27 03 PM

Watch the config folder for file changes

Currently, there's a manual refresh option in v3.3 (added via #24) but in the future I'd like to watch the config folder for file changes, so that when a file in the config folder changes, PHP Monitor automatically reloads the PHP installation information.

Important note: The folder watcher should stop watching when the PHP version changes, and start watching again. It should do this without leaking memory, so I should be careful about retain cycles here.

Warn about configuration issues

I ran into these myself when I tried setting up PHP 7.1 while PHP Monitor was active. After installing a new PHP version, you should run valet use php@XX which correctly sets up the project.

1. Detect incorrect php-fpm configuration

Check for the valet-fpm.conf file in $homebrew/etc/php/$version/php-fpm.d. (on PHP > 5.6) If that file is missing, tell the user that they'll need to run valet install after running.

Possible error prompt:

It seems like this is the first time you've switched to this version of PHP. Valet hasn't been set up for PHP-FPM yet. Please run valet install in your terminal to ensure that the correct configuration file has been created. If you don't do this, visits to .test domains will result in a 502 Bad Gateway error.

How that file is set up: https://github.com/laravel/valet/blob/d312a588f352c4b5c62b75c4abd1897403b04b76/cli/Valet/PhpFpm.php#L66

2. Detect composer dependency issues

Valet might not run and show an error similar to:

PHP Fatal error:  Composer detected issues in your platform: Your Composer dependencies require a PHP version ">= 7.2.5". You are running 7.1.33. in /Users/dive/.composer/vendor/composer/platform_check.php on line 24

Possible error prompt:

PHP X.X is now active, but your global Composer dependencies likely need to be updated. Your Composer dependencies require a PHP version ">= 7.2.5". You are running 7.1.33.

For both of these issues, PHP Monitor should warn you after switching. The first issue will result in a 502 (bad gateway) and the second issue will prevent Valet commands from running.

Current project status

As it's almost the middle of summer here, I think it's time to re-evaluate the project as it exists today. I'm happy with the current build and I have no plans to add features to v3.x. I think people are happy to use the app as-is, with no major complaints.

To be looked at in Q4

  • Testing PHP 8.1 compatibility again (since that is coming later this year)
  • Testing Monterey compatibility (should not be an issue but should be tested again prior to general availability)

Update: PHP Monitor 3.5 is now available with Monterey and PHP 8.1 support.

Road to 4.0

The issues that were planned for 4.0 have been implemented. Depending on whether there is more time or not, I might add additional quality of life changes.

These issues are done (pending release) or closed: #48, #26 and #32

Valet extension for 4.1

If the Valet extension API is still happening I might look into that too, but for now I'm going to stick with the issues mentioned above for 4.0, and plugging into Valet might be a 4.1 thing.

Check icon and version with taller menu bar on new MacBook Pros

I won't own one of these myself so if something is wrong with the icon and/or version number in the menu bar, please let me know β€” the menu bar is taller on those.

Once these machines ship, if someone could post a screenshot of what the menu bar item looks like, that would be great.

Release notarized binaries from now on

Who likes Gatekeeper being annoying because the app is not signed with a developer ID and/or because of a lack of notarization? No one.

image

Close this issue when v2.1 is released (notarized version).

Build menu with result builders

It would be nice to replace this:

let menu = StatusMenu()

// Add the PHP versions (or error messages)
menu.addPhpVersionMenuItems()
menu.addItem(NSMenuItem.separator())

// Add the possible actions
menu.addPhpActionMenuItems()
menu.addItem(NSMenuItem.separator())       

// Add information about services & actions
menu.addPhpConfigurationMenuItems()
menu.addItem(NSMenuItem.separator())

With something more like this:

let menu = buildMenu {
    Title("You are running PHP \(phpVersion.major)")
    MenuItemSeparator()

    if (!busy && phpVersions.count > 1) {
        MenuItems(for: .versionSwitch)
        MenuItemSeparator()
    }

    Title("Active Services")
    MenuItems(for: .services)
    MenuItemSeparator()

    Title("Configuration")
    MenuItems(for: .configuration)
    MenuItemSeparator()

    LimitsView()

    Title("Detected Extensions")
    MenuItems(for: .extensions)
    MenuItemSeparator()

    // and more
}

More reading here:

https://swiftbysundell.com/articles/deep-dive-into-swift-function-builders/
https://www.swiftbysundell.com/tips/annotating-properties-with-result-builder-attributes/
https://github.com/apple/swift-evolution/blob/main/proposals/0289-result-builders.md

PHP 8.0 support

Currently, detection of PHP 8.0 environments has been enabled.

You currently do need PHP 7.4 installed with the current release version of PHP Monitor.

(When PHP 8.0 releases, I will prepare an update for PHP Monitor. The minimum required version of Laravel Valet might go up as a consequence.)

macOS Mojave support

I tried installed the software, but its telling 'Laravel Valet is not correctly installed'. I already installed valet and type command 'which valet' and its return '/usr/local/bin/valet'.

Thank you :)

Screenshot 2021-02-19 at 8 49 43 PM

Add option to see terminal output

Currently, on develop, the option to view all executed commands can be seen:

image

If something goes wrong, it's easier to put the output of the commands here.

Refresh option?

Wondering if you think it would be useful to add a 'Refresh' option into the menu? For example, if I install a PHP extension or change my memory limit, I have to restart phpmon to see those changes. Thoughts?

Info about macOS Monterey compatibility

I don't see any particular reason why future versions of macOS would have issues running PHP Monitor, but during today's WWDC, macOS Monterey was just announced; when I have time I will be testing if PHP Monitor works correctly on the new OS and adjust the documentation accordingly.

Ensure the app does not crash at launch if an alert is displayed

In certain scenarios, PHP Monitor will just crash or continue checking for additional issues once an alert is presented upon startup. In reality, what should occur is as follows:

  • Stop execution of the startup procedure when an issue is found
  • Notify the user via an alert
  • Wait for the user to click "OK"
  • Terminate the application

502 Bad Gateway

When switching from PHP 5.6 to 7.3, I get a 502 on my .test domains set up with Laravel Valet.

Won't launch due to Valet: allow launch if Valet exists in ~/.composer

As reported in #23, some folks still seem to have issues getting the app to launch (the pre-flight checks fail).

During the launch checks, I should also look for Valet in ~/.composer/vendor/bin/valet.

A workaround for users is currently:

ln -s ~/.composer/vendor/bin/valet /usr/local/bin/valet

This will satisfy PHP Monitor's check in /usr/local/bin/valet.

MacOS M1 can't start application

First of all, Thanks for your amazing project.

When I use this package to my Mac Mini, It's still alert Valet has not been added to shudders.d, That's OK for my Intel MacOS system.

Xnip2021-03-12_13-41-56

I already Run sudo valet trust, but the error is still exists.

And the follow code is generated

# /etc/sudoers.d/valet
Cmnd_Alias VALET = /opt/homebrew/bin/valet *
%admin ALL=(root) NOPASSWD:SETENV: VALET

# /etc/sudoers.d/brew
Cmnd_Alias BREW = /opt/homebrew/bin/brew *
%admin ALL=(root) NOPASSWD:SETENV: BREW

PHP and Valet version info:

➜  ~ php -v
PHP 7.4.16 (cli) (built: Mar  4 2021 16:12:19) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.16, Copyright (c), by Zend Technologies
➜  ~ valet --version
Laravel Valet 2.13.19

Please give me some ideas, Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.