From c7ee4b8838d92fe0edff2efca543ad62e738d242 Mon Sep 17 00:00:00 2001 From: Nico Verbruggen Date: Sun, 14 May 2023 11:47:35 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Update=20README,=20check=20for=20br?= =?UTF-8?q?oken=20formulae?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 11 +++++--- phpmon/Domain/App/Startup.swift | 15 +++++++++++ .../Integrations/Homebrew/BrewFormula.swift | 6 +++++ phpmon/Domain/Menu/StatusMenu.swift | 1 + .../Domain/Preferences/PreferencesTabs.swift | 1 + phpmon/Domain/Presets/Preset.swift | 1 + .../SwiftUI/PhpManager/PhpFormulaeView.swift | 25 +++++++++++-------- phpmon/Localizable.strings | 6 +++++ 8 files changed, 52 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 7d6d471..9a8ebc8 100644 --- a/README.md +++ b/README.md @@ -25,15 +25,14 @@ PHP Monitor is a universal application that runs natively on Apple Silicon **and * macOS 12.4 or later (Monterey and Ventura are supported) * Homebrew is installed in `/usr/local/homebrew` or `/opt/homebrew` * Homebrew `php` formula is installed -* Laravel Valet (works with Valet v2, v3 and v4) -_You may need to update your Valet installation to keep everything working if a major version update of PHP has been released. You can do this by running `composer global update && valet install`. Some features are not supported when running Valet 2._ +_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](./SECURITY.md) to find out which version of the app is currently supported. ## 🚀 How to install -Again, make sure you have **[Laravel Valet](https://laravel.com/docs/master/valet)** installed first: +Again, if you want to have access to *all features* of PHP Monitor, I recommend installing **[Laravel Valet](https://laravel.com/docs/master/valet)** first: ```sh composer global require laravel/valet @@ -41,6 +40,8 @@ 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](https://github.com/nicoverbruggen/phpmon/releases/latest), unzip it and place it in `/Applications`. @@ -126,7 +127,9 @@ If you encounter a strange scenario or a malfunction, please open an issue on th
I want PHP Monitor to start up when I boot my Mac! -You can do this by dragging *PHP Monitor.app* into the **Login Items** section in **System Preferences > Users & Groups** for your account. +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!
diff --git a/phpmon/Domain/App/Startup.swift b/phpmon/Domain/App/Startup.swift index 81941da..cea3bbf 100644 --- a/phpmon/Domain/App/Startup.swift +++ b/phpmon/Domain/App/Startup.swift @@ -135,6 +135,21 @@ class Startup { descriptionText: "startup.errors.php_binary.desc".localized(Paths.php) ), // ================================================================================= + // Ensure that the main PHP installation is not broken. + // ================================================================================= + EnvironmentCheck( + command: { + return await Shell.pipe("\(Paths.binPath)/php -v").err + .contains("Library not loaded") + }, + name: "`no dyld issue detected", + titleText: "startup.errors.dyld_library.title".localized, + subtitleText: "startup.errors.dyld_library.subtitle".localized( + Paths.optPath + ), + descriptionText: "startup.errors.dyld_library.desc".localized + ), + // ================================================================================= // The Valet binary must exist. // ================================================================================= EnvironmentCheck( diff --git a/phpmon/Domain/Integrations/Homebrew/BrewFormula.swift b/phpmon/Domain/Integrations/Homebrew/BrewFormula.swift index c6076a9..37c38b8 100644 --- a/phpmon/Domain/Integrations/Homebrew/BrewFormula.swift +++ b/phpmon/Domain/Integrations/Homebrew/BrewFormula.swift @@ -49,6 +49,12 @@ struct BrewFormula { return VersionNumber.make(from: version)?.short ?? nil } + /// A quick variable that you can check to see if the install is unhealthy. + /// Will report true if no health information is available. + var healthy: Bool { + return isHealthy() ?? true + } + /** * Determines if this PHP installation is healthy. * Uses the cached installation health check as basis. diff --git a/phpmon/Domain/Menu/StatusMenu.swift b/phpmon/Domain/Menu/StatusMenu.swift index f5c8a31..84e8822 100644 --- a/phpmon/Domain/Menu/StatusMenu.swift +++ b/phpmon/Domain/Menu/StatusMenu.swift @@ -72,4 +72,5 @@ class StatusMenu: NSMenu { addCoreMenuItems() } + // swiftlint:enable cyclomatic_complexity } diff --git a/phpmon/Domain/Preferences/PreferencesTabs.swift b/phpmon/Domain/Preferences/PreferencesTabs.swift index 746356d..1df4bcb 100644 --- a/phpmon/Domain/Preferences/PreferencesTabs.swift +++ b/phpmon/Domain/Preferences/PreferencesTabs.swift @@ -65,6 +65,7 @@ class MenuStructurePreferencesVC: GenericPreferenceVC { return vc } + // swiftlint:enable line_length } class NotificationPreferencesVC: GenericPreferenceVC { diff --git a/phpmon/Domain/Presets/Preset.swift b/phpmon/Domain/Presets/Preset.swift index b40dc2e..3af88b4 100644 --- a/phpmon/Domain/Presets/Preset.swift +++ b/phpmon/Domain/Presets/Preset.swift @@ -196,6 +196,7 @@ struct Preset: Codable, Equatable { + info + "" + "" } + // swiftlint:enable void_function_in_ternary // MARK: - Reverting diff --git a/phpmon/Domain/SwiftUI/PhpManager/PhpFormulaeView.swift b/phpmon/Domain/SwiftUI/PhpManager/PhpFormulaeView.swift index 5a19f5c..0b311bf 100644 --- a/phpmon/Domain/SwiftUI/PhpManager/PhpFormulaeView.swift +++ b/phpmon/Domain/SwiftUI/PhpManager/PhpFormulaeView.swift @@ -137,16 +137,6 @@ struct PhpFormulaeView: View { VStack(alignment: .leading) { Text(formula.displayName).bold() - /* - if formula.isHealthy() == nil { - Text("Unknown health") - } else { - Text(formula.isHealthy()! ? "Health OK" : "Broken!") - } - - Text(formula.homebrewFolder) - */ - if formula.isInstalled && formula.hasUpgrade { Text("\(formula.installedVersion!) installed, \(formula.upgradeVersion!) available.") .font(.system(size: 11)) @@ -159,6 +149,12 @@ struct PhpFormulaeView: View { .font(.system(size: 11)) .foregroundColor(.gray) } + + if !formula.healthy { + Text("This PHP installation is broken.") + .font(.system(size: 11)) + .foregroundColor(.red) + } } .frame(maxWidth: .infinity, alignment: .leading) @@ -212,6 +208,14 @@ struct PhpFormulaeView: View { } } + public func repairAll() async { + await self.runCommand(InstallAndUpgradeCommand( + title: "Repairing installations...", + upgrading: [], + installing: [] + )) + } + public func upgradeAll(_ formulae: [BrewFormula]) async { await self.runCommand(InstallAndUpgradeCommand( title: "Installing updates...", @@ -321,6 +325,7 @@ struct PhpFormulaeView: View { } } } +// swiftlint:enable type_body_length struct PhpFormulaeView_Previews: PreviewProvider { static var previews: some View { diff --git a/phpmon/Localizable.strings b/phpmon/Localizable.strings index 2ea472e..6f1bde2 100644 --- a/phpmon/Localizable.strings +++ b/phpmon/Localizable.strings @@ -574,6 +574,12 @@ You can do this by running `composer global update` in your terminal. After that "startup.errors.php_opt.subtitle" = "The PHP alias was not found in `%@`. The app will not work correctly until you resolve this issue."; "startup.errors.php_opt.desc" = "If you already have the `php` formula installed, you may need to run `brew install php` in order for PHP Monitor to detect this installation."; +/// PHP binary is broken +"startup.errors.dyld_library.title" = "PHP is installed, but appears to be broken"; +"startup.errors.dyld_library.subtitle" = "When PHP Monitor is attempting to run commands, it is failing to do so correctly. This is usually an indicator of a broken PHP installation."; +"startup.errors.dyld_library.desc" = "Running `brew reinstall php && brew link php` in your Terminal may resolve this issue, so please give that a try."; + +/// Valet is not installed "startup.errors.valet_executable.title" = "Laravel Valet is not correctly installed"; "startup.errors.valet_executable.subtitle" = "You must install Valet with Composer. The app will not work correctly until you resolve this issue."; "startup.errors.valet_executable.desc" = "If you haven't installed Laravel Valet yet, please do so first. If you have it installed but are seeing this message anyway, then try running `which valet` in Terminal, it should return: `%@`.";