mirror of
https://github.com/nicoverbruggen/phpmon.git
synced 2025-08-08 04:20:07 +02:00
Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
cb504cc3f0 | |||
7c08a2fdfe | |||
2f47610c85 | |||
cc6324b692 | |||
15d75a7f98 | |||
c7c5311ff9 |
@ -112,6 +112,7 @@
|
||||
C43A8A1A25D9CD1000591B77 /* Utility.swift in Sources */ = {isa = PBXBuildFile; fileRef = C43A8A1925D9CD1000591B77 /* Utility.swift */; };
|
||||
C43A8A2025D9D1D700591B77 /* brew-formula.json in Resources */ = {isa = PBXBuildFile; fileRef = C43A8A1F25D9D1D700591B77 /* brew-formula.json */; };
|
||||
C43A8A2425D9D20D00591B77 /* HomebrewPackageTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = C43A8A2325D9D20D00591B77 /* HomebrewPackageTest.swift */; };
|
||||
C43FDBE929A932B0003D85EC /* PhpConfigChecker.swift in Sources */ = {isa = PBXBuildFile; fileRef = C43FDBE829A932B0003D85EC /* PhpConfigChecker.swift */; };
|
||||
C44067F527E2582B0045BD4E /* DomainListNameCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = C44067F427E2582B0045BD4E /* DomainListNameCell.swift */; };
|
||||
C44067F727E258410045BD4E /* DomainListPhpCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = C44067F627E258410045BD4E /* DomainListPhpCell.swift */; };
|
||||
C44067F927E2585E0045BD4E /* DomainListTypeCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = C44067F827E2585E0045BD4E /* DomainListTypeCell.swift */; };
|
||||
@ -811,6 +812,7 @@
|
||||
C43A8A1925D9CD1000591B77 /* Utility.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Utility.swift; sourceTree = "<group>"; };
|
||||
C43A8A1F25D9D1D700591B77 /* brew-formula.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = "brew-formula.json"; sourceTree = "<group>"; };
|
||||
C43A8A2325D9D20D00591B77 /* HomebrewPackageTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomebrewPackageTest.swift; sourceTree = "<group>"; };
|
||||
C43FDBE829A932B0003D85EC /* PhpConfigChecker.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PhpConfigChecker.swift; sourceTree = "<group>"; };
|
||||
C44067F427E2582B0045BD4E /* DomainListNameCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DomainListNameCell.swift; sourceTree = "<group>"; };
|
||||
C44067F627E258410045BD4E /* DomainListPhpCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DomainListPhpCell.swift; sourceTree = "<group>"; };
|
||||
C44067F827E2585E0045BD4E /* DomainListTypeCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DomainListTypeCell.swift; sourceTree = "<group>"; };
|
||||
@ -1219,6 +1221,7 @@
|
||||
C422DDAB28A2DAA100CEAC97 /* Warnings */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
C43FDBE729A9329A003D85EC /* Services */,
|
||||
C47699F028A2F3150060FEB8 /* Warning.swift */,
|
||||
C47699EE28A2F2A30060FEB8 /* WarningManager.swift */,
|
||||
C422DDAC28A2DAC600CEAC97 /* WarningsWindowController.swift */,
|
||||
@ -1244,6 +1247,14 @@
|
||||
path = Warning;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
C43FDBE729A9329A003D85EC /* Services */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
C43FDBE829A932B0003D85EC /* PhpConfigChecker.swift */,
|
||||
);
|
||||
path = Services;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
C44067F327E256560045BD4E /* Cells */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
@ -2155,6 +2166,7 @@
|
||||
C4D9ADC8277611A0007277F4 /* InternalSwitcher.swift in Sources */,
|
||||
C4FACE83288F1F9700FC478F /* OnboardingWindowController.swift in Sources */,
|
||||
C4080FFA27BD956700BF2C6B /* BetterAlertVC.swift in Sources */,
|
||||
C43FDBE929A932B0003D85EC /* PhpConfigChecker.swift in Sources */,
|
||||
C4BF56AB2949381100379603 /* FakeValetInteractor.swift in Sources */,
|
||||
C4B5635E276AB09000F12CCB /* VersionExtractor.swift in Sources */,
|
||||
C451AFF62969E40F0078E617 /* HelpButton.swift in Sources */,
|
||||
@ -2792,7 +2804,7 @@
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
MACOSX_DEPLOYMENT_TARGET = 11.0;
|
||||
MACOSX_DEPLOYMENT_TARGET = 12.4;
|
||||
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
|
||||
MTL_FAST_MATH = YES;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
@ -2849,7 +2861,7 @@
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
MACOSX_DEPLOYMENT_TARGET = 11.0;
|
||||
MACOSX_DEPLOYMENT_TARGET = 12.4;
|
||||
MTL_ENABLE_DEBUG_INFO = NO;
|
||||
MTL_FAST_MATH = YES;
|
||||
SDKROOT = macosx;
|
||||
@ -2867,7 +2879,7 @@
|
||||
CODE_SIGN_IDENTITY = "Apple Development";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
CURRENT_PROJECT_VERSION = 1070;
|
||||
CURRENT_PROJECT_VERSION = 1074;
|
||||
DEAD_CODE_STRIPPING = YES;
|
||||
DEBUG = YES;
|
||||
DEVELOPMENT_TEAM = 8M54J5J787;
|
||||
@ -2879,7 +2891,7 @@
|
||||
"$(inherited)",
|
||||
"@executable_path/../Frameworks",
|
||||
);
|
||||
MACOSX_DEPLOYMENT_TARGET = 11.0;
|
||||
MACOSX_DEPLOYMENT_TARGET = 12.4;
|
||||
MARKETING_VERSION = 5.8;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.nicoverbruggen.phpmon;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
@ -2897,7 +2909,7 @@
|
||||
CODE_SIGN_IDENTITY = "Apple Development";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
CURRENT_PROJECT_VERSION = 1070;
|
||||
CURRENT_PROJECT_VERSION = 1074;
|
||||
DEAD_CODE_STRIPPING = YES;
|
||||
DEBUG = NO;
|
||||
DEVELOPMENT_TEAM = 8M54J5J787;
|
||||
@ -2909,7 +2921,7 @@
|
||||
"$(inherited)",
|
||||
"@executable_path/../Frameworks",
|
||||
);
|
||||
MACOSX_DEPLOYMENT_TARGET = 11.0;
|
||||
MACOSX_DEPLOYMENT_TARGET = 12.4;
|
||||
MARKETING_VERSION = 5.8;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.nicoverbruggen.phpmon;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
@ -3108,7 +3120,7 @@
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
MACOSX_DEPLOYMENT_TARGET = 11.0;
|
||||
MACOSX_DEPLOYMENT_TARGET = 12.4;
|
||||
MTL_ENABLE_DEBUG_INFO = NO;
|
||||
MTL_FAST_MATH = YES;
|
||||
SDKROOT = macosx;
|
||||
@ -3126,7 +3138,7 @@
|
||||
CODE_SIGN_IDENTITY = "Apple Development";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
CURRENT_PROJECT_VERSION = 1070;
|
||||
CURRENT_PROJECT_VERSION = 1074;
|
||||
DEBUG = NO;
|
||||
DEVELOPMENT_TEAM = 8M54J5J787;
|
||||
ENABLE_HARDENED_RUNTIME = YES;
|
||||
@ -3137,7 +3149,7 @@
|
||||
"$(inherited)",
|
||||
"@executable_path/../Frameworks",
|
||||
);
|
||||
MACOSX_DEPLOYMENT_TARGET = 11.0;
|
||||
MACOSX_DEPLOYMENT_TARGET = 12.4;
|
||||
MARKETING_VERSION = 5.8;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.nicoverbruggen.phpmon.dev;
|
||||
PRODUCT_NAME = "$(TARGET_NAME) DEV";
|
||||
@ -3218,7 +3230,7 @@
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
MACOSX_DEPLOYMENT_TARGET = 11.0;
|
||||
MACOSX_DEPLOYMENT_TARGET = 12.4;
|
||||
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
|
||||
MTL_FAST_MATH = YES;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
@ -3237,7 +3249,7 @@
|
||||
CODE_SIGN_IDENTITY = "Apple Development";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
CURRENT_PROJECT_VERSION = 1070;
|
||||
CURRENT_PROJECT_VERSION = 1074;
|
||||
DEBUG = YES;
|
||||
DEVELOPMENT_TEAM = 8M54J5J787;
|
||||
ENABLE_HARDENED_RUNTIME = YES;
|
||||
@ -3248,7 +3260,7 @@
|
||||
"$(inherited)",
|
||||
"@executable_path/../Frameworks",
|
||||
);
|
||||
MACOSX_DEPLOYMENT_TARGET = 11.0;
|
||||
MACOSX_DEPLOYMENT_TARGET = 12.4;
|
||||
MARKETING_VERSION = 5.8;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.nicoverbruggen.phpmon.dev;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
|
@ -24,7 +24,7 @@ You can also add new domains as links, isolate sites, manage various services, a
|
||||
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 11 Big Sur or later
|
||||
* 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)
|
||||
|
@ -6,7 +6,7 @@ Generally speaking, only the latest version of **PHP Monitor** is supported, exc
|
||||
|
||||
| Version | Apple Silicon | Supported | Supported macOS | Deployment Target | Detected PHP Versions | Recommended Valet Version |
|
||||
| ------- | ------------- | ------------------ | ----- | ----- | ----- | ----
|
||||
| 5.7 | ✅ Universal binary | ✅ Yes | Big Sur (11.0)<br/>Monterey (12.0)<br/>Ventura (13.0) | macOS 11+ | PHP 5.6—PHP 8.2 (w/ Valet 2.x)<br/>PHP 7.0—PHP 8.2 (w/ Valet 3.x)<br/>PHP 7.1-PHP 8.2 (w/ Valet 4.x*) | 3.0 or higher recommended<br/> 2.16.2 minimum |
|
||||
| 5.8 | ✅ Universal binary | ✅ Yes | Monterey (12.4+)<br/>Ventura (13.0+) | macOS 12.4 | PHP 5.6—PHP 8.2 (w/ Valet 2.x)<br/>PHP 7.0—PHP 8.2 (w/ Valet 3.x)<br/>PHP 7.1-PHP 8.2 (w/ Valet 4.x*) | 3.0 or higher recommended<br/> 2.16.2 minimum |
|
||||
|
||||
(*) Preliminary listing. Valet 4 hasn't been released yet and the versions of PHP Valet can work with might still change.
|
||||
|
||||
@ -16,6 +16,7 @@ These versions of PHP Monitor are no longer supported, but if you’re using an
|
||||
|
||||
| Version | Apple Silicon | Supported | Supported macOS | Deployment Target | Detected PHP Versions | Minimum Required Valet Version |
|
||||
| ------- | ------------- | ------------------ | ----- | ----- | ----- | ----
|
||||
| 5.7 | ✅ Universal binary | ❌ | Big Sur (11.0)<br/>Monterey (12.0)<br/>Ventura (13.0)* | macOS 11+ | PHP 5.6—PHP 8.2 (w/ Valet 2.x)<br/>PHP 7.0—PHP 8.2 (w/ Valet 3.x) | 3.0 recommended<br/> 2.16.2 minimum |
|
||||
| 5.6 | ✅ Universal binary | ❌ | Big Sur (11.0)<br/>Monterey (12.0)<br/>Ventura (13.0)* | macOS 11+ | PHP 5.6—PHP 8.2 (w/ Valet 2.x)<br/>PHP 7.0—PHP 8.2 (w/ Valet 3.x) | 3.0 recommended<br/> 2.16.2 minimum |
|
||||
| 4.1 | ✅ Universal binary | ❌ | Big Sur (11.0)<br/>Monterey (12.0) | macOS 11+ | PHP 5.6—PHP 8.2 | 2.16.2 |
|
||||
| 4.0 | ✅ Universal binary | ❌ | Big Sur (11.0)<br/>Monterey (12.0) | macOS 10.14+ | PHP 5.6—PHP 8.2 | 2.13 |
|
||||
|
@ -9,6 +9,7 @@
|
||||
import Foundation
|
||||
import Cocoa
|
||||
|
||||
@MainActor
|
||||
class BetterAlert {
|
||||
|
||||
var windowController: NSWindowController!
|
||||
|
@ -231,7 +231,7 @@ class GeneralPreferencesVC: GenericPreferenceVC {
|
||||
// MARK: - Lifecycle
|
||||
|
||||
public static func fromStoryboard() -> GenericPreferenceVC {
|
||||
var vc = NSStoryboard(name: "Main", bundle: nil)
|
||||
let vc = NSStoryboard(name: "Main", bundle: nil)
|
||||
.instantiateController(withIdentifier: "preferencesTemplateVC") as! GenericPreferenceVC
|
||||
|
||||
vc.views = [
|
||||
|
@ -142,42 +142,50 @@ class Stats {
|
||||
}
|
||||
|
||||
public static func evaluateLastLinkedPhpVersion() {
|
||||
let currentVersion = PhpEnv.phpInstall.version.short
|
||||
let currentVersion = PhpEnv.phpInstall.version?.short ?? ""
|
||||
let previousVersion = Stats.lastGlobalPhpVersion
|
||||
|
||||
// Save the PHP version that is currently in use (only if unknown)
|
||||
if Stats.lastGlobalPhpVersion == "" {
|
||||
if currentVersion == "" {
|
||||
return Log.warn("<PG> PHP Guard is unable to determine the current PHP version!")
|
||||
}
|
||||
Log.info("<PG> The currently linked version of PHP is: \(currentVersion).")
|
||||
|
||||
if previousVersion == "" {
|
||||
Stats.persistCurrentGlobalPhpVersion(version: currentVersion)
|
||||
Log.info("Persisting the currently linked PHP version (first time only).")
|
||||
} else {
|
||||
Log.info("Previously, the globally linked PHP version was: \(previousVersion).")
|
||||
if previousVersion != currentVersion {
|
||||
Log.info("Currently, that version is: \(currentVersion). This is a mismatch.")
|
||||
Task { @MainActor in
|
||||
BetterAlert()
|
||||
.withInformation(
|
||||
title: "startup.version_mismatch.title".localized,
|
||||
subtitle: "startup.version_mismatch.subtitle".localized(
|
||||
currentVersion,
|
||||
previousVersion
|
||||
),
|
||||
description: "startup.version_mismatch.desc".localized()
|
||||
)
|
||||
.withPrimary(text: "startup.version_mismatch.button_switch_back".localized(
|
||||
previousVersion
|
||||
), action: { alert in
|
||||
alert.close(with: .OK)
|
||||
Task { MainMenu.shared.switchToAnyPhpVersion(previousVersion) }
|
||||
})
|
||||
.withTertiary(text: "startup.version_mismatch.button_stay".localized(
|
||||
currentVersion
|
||||
), action: { alert in
|
||||
Stats.persistCurrentGlobalPhpVersion(version: currentVersion)
|
||||
alert.close(with: .OK)
|
||||
})
|
||||
.show()
|
||||
}
|
||||
}
|
||||
return Log.warn("<PG> PHP Guard is saving the currently linked PHP version (first time only).")
|
||||
}
|
||||
Log.info("<PG> Previously, the globally linked PHP version was: \(previousVersion).")
|
||||
|
||||
if previousVersion == currentVersion {
|
||||
return Log.info("<PG> PHP Guard did not notice any changes in the linked PHP version.")
|
||||
}
|
||||
|
||||
// At this point, the version is *not* a match
|
||||
Log.info("<PG> PHP Guard noticed a different PHP version. An alert will be displayed!")
|
||||
|
||||
Task { @MainActor in
|
||||
BetterAlert()
|
||||
.withInformation(
|
||||
title: "startup.version_mismatch.title".localized,
|
||||
subtitle: "startup.version_mismatch.subtitle".localized(
|
||||
currentVersion,
|
||||
previousVersion
|
||||
),
|
||||
description: "startup.version_mismatch.desc".localized()
|
||||
)
|
||||
.withPrimary(text: "startup.version_mismatch.button_switch_back".localized(
|
||||
previousVersion
|
||||
), action: { alert in
|
||||
alert.close(with: .OK)
|
||||
Task { MainMenu.shared.switchToAnyPhpVersion(previousVersion) }
|
||||
})
|
||||
.withTertiary(text: "startup.version_mismatch.button_stay".localized(
|
||||
currentVersion
|
||||
), action: { alert in
|
||||
Stats.persistCurrentGlobalPhpVersion(version: currentVersion)
|
||||
alert.close(with: .OK)
|
||||
})
|
||||
.show()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -59,15 +59,12 @@ protocol CheckboxPreferenceViewBehavior {
|
||||
|
||||
class CheckboxPreferenceBehavior: CheckboxPreferenceViewBehavior {
|
||||
var button: NSButton
|
||||
var preference: PreferenceName {
|
||||
didSet {
|
||||
button.state = Preferences.isEnabled(self.preference) ? .on : .off
|
||||
}
|
||||
}
|
||||
var preference: PreferenceName
|
||||
|
||||
init(button: NSButton, preference: PreferenceName) {
|
||||
self.button = button
|
||||
self.preference = preference
|
||||
self.button = button
|
||||
self.button.state = Preferences.isEnabled(self.preference) ? .on : .off
|
||||
}
|
||||
|
||||
public func toggled(checked: Bool) {
|
||||
|
@ -9,10 +9,14 @@
|
||||
import SwiftUI
|
||||
|
||||
struct WarningListView: View {
|
||||
@State var warnings: [Warning]
|
||||
@ObservedObject var warningManager: WarningManager
|
||||
|
||||
init(empty: Bool = false) {
|
||||
self.warnings = empty ? [] : WarningManager.shared.warnings
|
||||
if empty {
|
||||
WarningManager.shared.warnings = []
|
||||
}
|
||||
|
||||
warningManager = WarningManager.shared
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
@ -40,7 +44,6 @@ struct WarningListView: View {
|
||||
Button("warnings.refresh.button".localizedForSwiftUI) {
|
||||
Task { // Reload warnings
|
||||
await WarningManager.shared.checkEnvironment()
|
||||
self.warnings = WarningManager.shared.warnings
|
||||
}
|
||||
}
|
||||
Text("warnings.refresh.button.description".localizedForSwiftUI)
|
||||
@ -51,14 +54,14 @@ struct WarningListView: View {
|
||||
|
||||
List {
|
||||
VStack(alignment: .leading, spacing: 0) {
|
||||
if warnings.isEmpty {
|
||||
if warningManager.warnings.isEmpty {
|
||||
NoWarningsView()
|
||||
} else {
|
||||
ForEach(warnings) { warning in
|
||||
ForEach(warningManager.warnings) { warning in
|
||||
Group {
|
||||
WarningView(
|
||||
title: warning.title,
|
||||
paragraphs: warning.paragraphs,
|
||||
paragraphs: warning.paragraphs(),
|
||||
documentationUrl: warning.url
|
||||
)
|
||||
.fixedSize(horizontal: false, vertical: true)
|
||||
@ -67,7 +70,8 @@ struct WarningListView: View {
|
||||
}.padding(5)
|
||||
}
|
||||
}
|
||||
}.frame(minHeight: 0, maxHeight: .infinity).padding(5)
|
||||
}
|
||||
.frame(minHeight: 0, maxHeight: .infinity).padding(5)
|
||||
}
|
||||
.listRowInsets(EdgeInsets())
|
||||
.listStyle(.plain)
|
||||
|
@ -26,7 +26,7 @@ struct WarningView: View {
|
||||
Text(title.localizedForSwiftUI)
|
||||
.fontWeight(.bold)
|
||||
ForEach(paragraphs, id: \.self) { paragraph in
|
||||
Text(paragraph.localizedForSwiftUI)
|
||||
Text(paragraph)
|
||||
.font(.system(size: 13))
|
||||
}
|
||||
}
|
||||
|
39
phpmon/Domain/Warnings/Services/PhpConfigChecker.swift
Normal file
39
phpmon/Domain/Warnings/Services/PhpConfigChecker.swift
Normal file
@ -0,0 +1,39 @@
|
||||
//
|
||||
// PhpConfigChecker.swift
|
||||
// PHP Monitor
|
||||
//
|
||||
// Created by Nico Verbruggen on 24/02/2023.
|
||||
// Copyright © 2023 Nico Verbruggen. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
class PhpConfigChecker {
|
||||
|
||||
public static var shared = PhpConfigChecker()
|
||||
|
||||
var missing: [String] = []
|
||||
|
||||
public func check() {
|
||||
missing = []
|
||||
|
||||
let shouldExist = [
|
||||
"php.ini",
|
||||
"php-fpm.conf",
|
||||
"php-fpm.d/valet-fpm.conf"
|
||||
]
|
||||
|
||||
for version in PhpEnv.shared.availablePhpVersions {
|
||||
for file in shouldExist {
|
||||
let fullFilePath = Paths.etcPath.appending("/php/\(version)/\(file)")
|
||||
if !FileSystem.fileExists(fullFilePath) {
|
||||
missing.append(fullFilePath)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if !missing.isEmpty {
|
||||
Log.warn("The following config file(s) were missing: \(missing)")
|
||||
}
|
||||
}
|
||||
}
|
@ -8,19 +8,27 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
struct Warning: Identifiable {
|
||||
struct Warning: Identifiable, Hashable {
|
||||
var id = UUID()
|
||||
let command: () async -> Bool
|
||||
let name: String
|
||||
let title: String
|
||||
let paragraphs: [String]
|
||||
let paragraphs: () -> [String]
|
||||
let url: String?
|
||||
|
||||
/**
|
||||
- Parameters:
|
||||
- command: The command that, if it returns true, means that a warning applies
|
||||
- name: The internal name or description for this warning
|
||||
- title: The title displayed for the user
|
||||
- paragraphs: The main body of text displayed for the user
|
||||
- url: The URL that one can navigate to for more information (if applicable)
|
||||
*/
|
||||
init(
|
||||
command: @escaping () async -> Bool,
|
||||
name: String,
|
||||
title: String,
|
||||
paragraphs: [String],
|
||||
paragraphs: @escaping () -> [String],
|
||||
url: String?
|
||||
) {
|
||||
self.command = command
|
||||
@ -33,4 +41,12 @@ struct Warning: Identifiable {
|
||||
public func applies() async -> Bool {
|
||||
return await self.command()
|
||||
}
|
||||
|
||||
public static func == (lhs: Warning, rhs: Warning) -> Bool {
|
||||
return lhs.hashValue == rhs.hashValue
|
||||
}
|
||||
|
||||
public func hash(into hasher: inout Hasher) {
|
||||
hasher.combine(self.id)
|
||||
}
|
||||
}
|
||||
|
@ -9,9 +9,9 @@
|
||||
import Foundation
|
||||
import Cocoa
|
||||
|
||||
class WarningManager {
|
||||
class WarningManager: ObservableObject {
|
||||
|
||||
static var shared = WarningManager()
|
||||
static var shared: WarningManager = WarningManager()
|
||||
|
||||
init() {
|
||||
if isRunningSwiftUIPreview {
|
||||
@ -26,8 +26,8 @@ class WarningManager {
|
||||
.trimmingCharacters(in: .whitespacesAndNewlines) == "1"
|
||||
},
|
||||
name: "Running PHP Monitor with Rosetta on M1",
|
||||
title: "warnings.arm_compatibility.title",
|
||||
paragraphs: ["warnings.arm_compatibility.description"],
|
||||
title: "warnings.arm_compatibility.title".localized,
|
||||
paragraphs: { return ["warnings.arm_compatibility.description".localized] },
|
||||
url: "https://github.com/nicoverbruggen/phpmon/wiki/PHP-Monitor-and-Apple-Silicon"
|
||||
),
|
||||
Warning(
|
||||
@ -36,13 +36,27 @@ class WarningManager {
|
||||
!FileSystem.isWriteableFile("/usr/local/bin/")
|
||||
},
|
||||
name: "Helpers cannot be symlinked and not in PATH",
|
||||
title: "warnings.helper_permissions.title",
|
||||
paragraphs: [
|
||||
"warnings.helper_permissions.description",
|
||||
"warnings.helper_permissions.unavailable",
|
||||
"warnings.helper_permissions.symlink"
|
||||
],
|
||||
title: "warnings.helper_permissions.title".localized,
|
||||
paragraphs: { return [
|
||||
"warnings.helper_permissions.description".localized,
|
||||
"warnings.helper_permissions.unavailable".localized,
|
||||
"warnings.helper_permissions.symlink".localized
|
||||
] },
|
||||
url: "https://github.com/nicoverbruggen/phpmon/wiki/PHP-Monitor-helper-binaries"
|
||||
),
|
||||
Warning(
|
||||
command: {
|
||||
PhpConfigChecker.shared.check()
|
||||
return !PhpConfigChecker.shared.missing.isEmpty
|
||||
},
|
||||
name: "Your PHP installation is missing configuration files",
|
||||
title: "warnings.files_missing.title".localized,
|
||||
paragraphs: { return [
|
||||
"warnings.files_missing.description".localized(
|
||||
PhpConfigChecker.shared.missing.joined(separator: "\n• ")
|
||||
)
|
||||
] },
|
||||
url: nil
|
||||
)
|
||||
]
|
||||
|
||||
@ -60,11 +74,11 @@ class WarningManager {
|
||||
Checks the user's environment and checks if any special warnings apply.
|
||||
*/
|
||||
func checkEnvironment() async {
|
||||
self.warnings = []
|
||||
|
||||
if ProcessInfo.processInfo.environment["EXTREME_DOCTOR_MODE"] != nil {
|
||||
// For debugging purposes, we may wish to see all possible evaluations listed
|
||||
self.warnings = self.evaluations
|
||||
Task { @MainActor in
|
||||
self.warnings = self.evaluations
|
||||
}
|
||||
} else {
|
||||
// Otherwise, loop over the actual evaluations and list the warnings
|
||||
await loopOverEvaluations()
|
||||
@ -74,9 +88,14 @@ class WarningManager {
|
||||
}
|
||||
|
||||
private func loopOverEvaluations() async {
|
||||
Task { @MainActor in
|
||||
self.warnings = []
|
||||
}
|
||||
for check in self.evaluations where await check.applies() {
|
||||
Log.info("[DOCTOR] \(check.name) (!)")
|
||||
self.warnings.append(check)
|
||||
Task { @MainActor in
|
||||
self.warnings.append(check)
|
||||
}
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
@ -661,6 +661,13 @@ COMMON TROUBLESHOOTING TIPS
|
||||
"warnings.arm_compatibility.title" = "You are running PHP Monitor using Rosetta on Apple Silicon, which means your PHP environment is also running via Rosetta.";
|
||||
"warnings.arm_compatibility.description" = "You appear to be running an ARM-compatible version of macOS, but you are currently running PHP Monitor using Rosetta. While this will work correctly, it is recommended that you use the native version of Homebrew.";
|
||||
|
||||
"warnings.files_missing.title" = "Your PHP installation is lacking required configuration files";
|
||||
"warnings.files_missing.description" = "The following files normally exist on a functional system:
|
||||
|
||||
• %@
|
||||
|
||||
When files like these are missing, it's recommended to reinstall the appropriate PHP version(s) via Homebrew again, which should restore the configuration files that are missing. Missing configuration files can be the reason why you get '502 Bad Gateway' errors, even after running Fix My Valet.";
|
||||
|
||||
"warnings.none" = "There are no recommendations available for you right now. You're all good!";
|
||||
|
||||
// ONBOARDING
|
||||
|
Reference in New Issue
Block a user