1
0
mirror of https://github.com/nicoverbruggen/phpmon.git synced 2026-03-27 22:40:08 +01:00

Add automatic fixes for taps, xdebug configuration

This commit is contained in:
2025-08-18 11:59:02 +02:00
parent 68cf12f584
commit fcaeaf1f6b
3 changed files with 71 additions and 2 deletions

View File

@@ -59,6 +59,66 @@ class WarningManager: ObservableObject {
await WarningManager.shared.checkEnvironment() await WarningManager.shared.checkEnvironment()
} }
), ),
Warning(
command: {
PhpEnvironments.shared.currentInstall?.extensions.contains { $0.name == "xdebug" } ?? false
&& !Xdebug.enabled
},
name: "Missing configuration file for `xdebug.mode`",
title: "warnings.xdebug_conf_missing.title",
paragraphs: { return [
"warnings.xdebug_conf_missing.description"
] },
url: "https://xdebug.org/docs/install#mode",
fix: {
if let php = PhpEnvironments.shared.currentInstall {
if let xdebug = php.extensions.first(where: { $0.name == "xdebug" }),
let original = try? FileSystem.getStringFromFile(xdebug.file) {
// Append xdebug.mode = off to the file
try? FileSystem.writeAtomicallyToFile(
xdebug.file,
content: original + "\nxdebug.mode = off"
)
// Reload extension configuration by updating PHP installation info (reload)
PhpEnvironments.shared.currentInstall = ActivePhpInstallation()
// Finally, reload warnings
await WarningManager.shared.checkEnvironment()
}
}
}
),
Warning(
command: {
!BrewDiagnostics.installedTaps.contains("shivammathur/php")
},
name: "`shivammathur/php` tap is missing",
title: "warnings.php_tap_missing.title",
paragraphs: { return [
"warnings.php_tap_missing.description"
] },
url: "https://github.com/shivammathur/homebrew-php",
fix: {
await Shell.quiet("brew tap shivammathur/php")
await WarningManager.shared.checkEnvironment()
}
),
Warning(
command: {
!BrewDiagnostics.installedTaps.contains("shivammathur/extensions")
},
name: "`shivammathur/extensions` tap is missing",
title: "warnings.extensions_tap_missing.title",
paragraphs: { return [
"warnings.extensions_tap_missing.description"
] },
url: "https://github.com/shivammathur/homebrew-extensions",
fix: {
await Shell.quiet("brew tap shivammathur/extensions")
await WarningManager.shared.checkEnvironment()
}
),
Warning( Warning(
command: { command: {
PhpConfigChecker.shared.check() PhpConfigChecker.shared.check()

View File

@@ -23,7 +23,7 @@ class PhpDoctorWindowController: PMWindowController {
guard let window = windowController.window else { return } guard let window = windowController.window else { return }
window.title = "" window.title = ""
window.styleMask = [.titled, .closable, .miniaturizable] window.styleMask = [.titled, .closable, .miniaturizable, .resizable]
window.titlebarAppearsTransparent = true window.titlebarAppearsTransparent = true
window.delegate = delegate ?? windowController window.delegate = delegate ?? windowController
window.contentView = NSHostingView(rootView: PhpDoctorView()) window.contentView = NSHostingView(rootView: PhpDoctorView())

View File

@@ -824,7 +824,7 @@ COMMON TROUBLESHOOTING TIPS
"warnings.description" = "**PHP Doctor** will suggest improvements to your active system configuration."; "warnings.description" = "**PHP Doctor** will suggest improvements to your active system configuration.";
"warnings.disclaimer" = "You may choose to hide all recommendations from the PHP Monitor menu in Preferences, but it is recommended that you deal with all actionable items."; "warnings.disclaimer" = "You may choose to hide all recommendations from the PHP Monitor menu in Preferences, but it is recommended that you deal with all actionable items.";
"warnings.refresh.button" = "Scan Again"; "warnings.refresh.button" = "Scan Again";
"warnings.refresh.button.description" = "Press this button once you've fixed an issue. This will cause PHP Monitor to re-evaluate your environment. If it's really fixed, the recommendation should disappear."; "warnings.refresh.button.description" = "Press this button if you've manually fixed an issue. This will cause PHP Monitor to re-evaluate your environment. (Automatic fixes do not require you to press this button.)";
"warnings.helper_permissions.title" = "PHP Monitors helpers are currently unavailable."; "warnings.helper_permissions.title" = "PHP Monitors helpers are currently unavailable.";
"warnings.helper_permissions.description" = "PHP Monitor comes with various helper scripts. Using these scripts allows you to easily invoke a specific version of PHP without switching the linked PHP version."; "warnings.helper_permissions.description" = "PHP Monitor comes with various helper scripts. Using these scripts allows you to easily invoke a specific version of PHP without switching the linked PHP version.";
@@ -841,6 +841,15 @@ COMMON TROUBLESHOOTING TIPS
When files like these are missing, you should switch to the PHP version associated with those files: that may resolve the problem. If this doesn't fix the issue, 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 (if you are using Valet)."; When files like these are missing, you should switch to the PHP version associated with those files: that may resolve the problem. If this doesn't fix the issue, 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 (if you are using Valet).";
"warnings.xdebug_conf_missing.title" = "Xdebug configuration is incomplete";
"warnings.xdebug_conf_missing.description" = "You have Xdebug installed, but no mode is specified. Would you like for PHP Monitor to update your configuration? You can also fix this manually.";
"warnings.php_tap_missing.title" = "`shivammathur/php` tap is missing";
"warnings.php_tap_missing.description" = "This Homebrew tap is required to install older PHP versions via this app's PHP Version Manager.";
"warnings.extensions_tap_missing.title" = "`shivammathur/extensions` tap is missing";
"warnings.extensions_tap_missing.description" = "This Homebrew tap is required to install extensions via this app's PHP Extension Manager.";
"warnings.none" = "There are no recommendations available for you right now. You're all good!"; "warnings.none" = "There are no recommendations available for you right now. You're all good!";
// ONBOARDING // ONBOARDING