diff --git a/phpmon/Common/PHP/PhpInstallation.swift b/phpmon/Common/PHP/PhpInstallation.swift index 0eb0126..5658747 100644 --- a/phpmon/Common/PHP/PhpInstallation.swift +++ b/phpmon/Common/PHP/PhpInstallation.swift @@ -45,7 +45,9 @@ class PhpInstallation { withStandardError: true ).trimmingCharacters(in: .whitespacesAndNewlines) - if testCommand.contains("Library not loaded") { + // If the "dyld: Library not loaded" issue pops up, we have an unhealthy PHP installation + // and we will need to reinstall this version of PHP via Homebrew. + if testCommand.contains("Library not loaded") && testCommand.contains("dyld") { self.isHealthy = false Log.err("The PHP installation of \(self.versionNumber.short) is not healthy!") } diff --git a/phpmon/Domain/Integrations/Homebrew/BrewFormula.swift b/phpmon/Domain/Integrations/Homebrew/BrewFormula.swift index 1ea7e32..c50483c 100644 --- a/phpmon/Domain/Integrations/Homebrew/BrewFormula.swift +++ b/phpmon/Domain/Integrations/Homebrew/BrewFormula.swift @@ -39,8 +39,19 @@ struct BrewFormula { return "\(Paths.optPath)/\(resolved)/bin" } - public func isHealthy() -> Bool { - return true - // #error("This must check if the PHP version works") + var shortVersion: String? { + guard let version = self.installedVersion else { + return nil + } + + return VersionNumber.make(from: version)?.short ?? nil + } + + public func isHealthy() -> Bool? { + guard let shortVersion = self.shortVersion else { + return nil + } + + return PhpEnv.shared.cachedPhpInstallations[shortVersion]?.isHealthy ?? nil } } diff --git a/phpmon/Domain/SwiftUI/PhpManager/PhpFormulaeView.swift b/phpmon/Domain/SwiftUI/PhpManager/PhpFormulaeView.swift index 1cd18e2..ac13164 100644 --- a/phpmon/Domain/SwiftUI/PhpManager/PhpFormulaeView.swift +++ b/phpmon/Domain/SwiftUI/PhpManager/PhpFormulaeView.swift @@ -133,7 +133,14 @@ struct PhpFormulaeView: View { .padding(.horizontal, 5) VStack(alignment: .leading) { Text(formula.displayName).bold() - // Text(formula.homebrewFolder) + + 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.")