mirror of
https://github.com/nicoverbruggen/phpmon.git
synced 2025-08-08 04:20:07 +02:00
🐛 Detect missing core php
formula (#66)
In rare cases, the version corresponding to the `php` formula might not be installed, but another alias is linked correctly. That means that the PHP binary is found, but the core formula is not. PHP Monitor will incorrectly report that it exists, which means the user can break their PHP installation. Oops. This quick fix handles that situation: - Checks if the PHP binary for the `php` aliased version exists (located in $optdir/php/bin/php) - Disables the force load option if the aliased version is missing (including a tweaked label if the version is missing)
This commit is contained in:
@ -23,7 +23,7 @@ class Actions {
|
||||
let phpAlias = App.shared.brewPhpVersion
|
||||
|
||||
// Avoid inserting a duplicate
|
||||
if (!versionsOnly.contains(phpAlias)) {
|
||||
if (!versionsOnly.contains(phpAlias) && Shell.fileExists("\(Paths.optPath)/php/bin/php")) {
|
||||
versionsOnly.append(phpAlias);
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,10 @@ class Valet {
|
||||
init() {
|
||||
version = Actions.valet("--version")
|
||||
.replacingOccurrences(of: "Laravel Valet ", with: "")
|
||||
// TODO: Use regular expression to avoid deprecation notices
|
||||
.split(separator: "\n").last?
|
||||
.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||
?? "UNKNOWN"
|
||||
|
||||
let file = FileManager.default.homeDirectoryForCurrentUser
|
||||
.appendingPathComponent(".config/valet/config.json")
|
||||
|
@ -114,7 +114,6 @@ class MainMenu: NSObject, NSWindowDelegate, NSMenuDelegate {
|
||||
menu.addItem(NSMenuItem.separator())
|
||||
|
||||
// Add Valet interactions
|
||||
|
||||
menu.addValetMenuItems()
|
||||
|
||||
// Add information about services & actions
|
||||
|
@ -81,11 +81,28 @@ class StatusMenu : NSMenu {
|
||||
}
|
||||
self.setSubmenu(servicesMenu, for: services)
|
||||
|
||||
self.addItem(NSMenuItem(title: "mi_force_load_latest".localized, action: #selector(MainMenu.forceRestartLatestPhp), keyEquivalent: "f"))
|
||||
self.addForceLoadLatestVersion()
|
||||
|
||||
self.addItem(services)
|
||||
self.addItem(NSMenuItem(title: "mi_restart_all_services".localized, action: #selector(MainMenu.restartAllServices), keyEquivalent: "s"))
|
||||
}
|
||||
|
||||
func addForceLoadLatestVersion() {
|
||||
if !App.shared.availablePhpVersions.contains(App.shared.brewPhpVersion) {
|
||||
self.addItem(NSMenuItem(
|
||||
title: "mi_force_load_latest_unavailable".localized
|
||||
.replacingOccurrences(of: "%@", with: App.shared.brewPhpVersion),
|
||||
action: nil, keyEquivalent: "f"
|
||||
))
|
||||
} else {
|
||||
self.addItem(NSMenuItem(
|
||||
title: "mi_force_load_latest".localized
|
||||
.replacingOccurrences(of: "%@", with: App.shared.brewPhpVersion),
|
||||
action: #selector(MainMenu.forceRestartLatestPhp), keyEquivalent: "f"))
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func addValetMenuItems() {
|
||||
self.addItem(HeaderView.asMenuItem(text: "mi_valet".localized))
|
||||
self.addItem(NSMenuItem(title: "mi_valet_config".localized, action: #selector(MainMenu.openValetConfigFolder), keyEquivalent: "v"))
|
||||
|
@ -25,7 +25,8 @@
|
||||
"mi_manage_services" = "Manage services";
|
||||
"mi_restart_all_services" = "Restart all services";
|
||||
"mi_stop_all_services" = "Stop all services";
|
||||
"mi_force_load_latest" = "Force load latest PHP version";
|
||||
"mi_force_load_latest" = "Force load (latest) PHP %@";
|
||||
"mi_force_load_latest_unavailable" = "Force load unavailable (PHP %@ not installed)";
|
||||
"mi_php_refresh" = "Refresh information";
|
||||
|
||||
"mi_configuration" = "Configuration";
|
||||
|
Reference in New Issue
Block a user