Skip to content

Commit cd37a8a

Browse files
🚀 Version 25.10.2
2 parents b4cda15 + b8e8a8d commit cd37a8a

File tree

6 files changed

+60
-18
lines changed

6 files changed

+60
-18
lines changed

PHP Monitor.xcodeproj/project.pbxproj

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3920,7 +3920,7 @@
39203920
CODE_SIGN_IDENTITY = "Apple Development";
39213921
CODE_SIGN_STYLE = Automatic;
39223922
COMBINE_HIDPI_IMAGES = YES;
3923-
CURRENT_PROJECT_VERSION = 1690;
3923+
CURRENT_PROJECT_VERSION = 1695;
39243924
DEAD_CODE_STRIPPING = YES;
39253925
DEBUG = YES;
39263926
ENABLE_APP_SANDBOX = NO;
@@ -3939,7 +3939,7 @@
39393939
"@executable_path/../Frameworks",
39403940
);
39413941
MACOSX_DEPLOYMENT_TARGET = 13.5;
3942-
MARKETING_VERSION = 25.10.1;
3942+
MARKETING_VERSION = 25.10.2;
39433943
PRODUCT_BUNDLE_IDENTIFIER = com.nicoverbruggen.phpmon;
39443944
PRODUCT_MODULE_NAME = PHP_Monitor;
39453945
PRODUCT_NAME = "$(TARGET_NAME)";
@@ -3964,7 +3964,7 @@
39643964
CODE_SIGN_IDENTITY = "Apple Development";
39653965
CODE_SIGN_STYLE = Automatic;
39663966
COMBINE_HIDPI_IMAGES = YES;
3967-
CURRENT_PROJECT_VERSION = 1690;
3967+
CURRENT_PROJECT_VERSION = 1695;
39683968
DEAD_CODE_STRIPPING = YES;
39693969
DEBUG = NO;
39703970
ENABLE_APP_SANDBOX = NO;
@@ -3983,7 +3983,7 @@
39833983
"@executable_path/../Frameworks",
39843984
);
39853985
MACOSX_DEPLOYMENT_TARGET = 13.5;
3986-
MARKETING_VERSION = 25.10.1;
3986+
MARKETING_VERSION = 25.10.2;
39873987
PRODUCT_BUNDLE_IDENTIFIER = com.nicoverbruggen.phpmon;
39883988
PRODUCT_MODULE_NAME = PHP_Monitor;
39893989
PRODUCT_NAME = "$(TARGET_NAME)";
@@ -4146,7 +4146,7 @@
41464146
CODE_SIGN_IDENTITY = "Apple Development";
41474147
CODE_SIGN_STYLE = Automatic;
41484148
COMBINE_HIDPI_IMAGES = YES;
4149-
CURRENT_PROJECT_VERSION = 1690;
4149+
CURRENT_PROJECT_VERSION = 1695;
41504150
DEAD_CODE_STRIPPING = YES;
41514151
DEBUG = YES;
41524152
ENABLE_APP_SANDBOX = NO;
@@ -4165,7 +4165,7 @@
41654165
"@executable_path/../Frameworks",
41664166
);
41674167
MACOSX_DEPLOYMENT_TARGET = 13.5;
4168-
MARKETING_VERSION = 25.10.1;
4168+
MARKETING_VERSION = 25.10.2;
41694169
PRODUCT_BUNDLE_IDENTIFIER = com.nicoverbruggen.phpmon.eap;
41704170
PRODUCT_MODULE_NAME = PHP_Monitor;
41714171
PRODUCT_NAME = "$(TARGET_NAME) EAP";
@@ -4339,7 +4339,7 @@
43394339
CODE_SIGN_IDENTITY = "Apple Development";
43404340
CODE_SIGN_STYLE = Automatic;
43414341
COMBINE_HIDPI_IMAGES = YES;
4342-
CURRENT_PROJECT_VERSION = 1690;
4342+
CURRENT_PROJECT_VERSION = 1695;
43434343
DEAD_CODE_STRIPPING = YES;
43444344
DEBUG = NO;
43454345
ENABLE_APP_SANDBOX = NO;
@@ -4358,7 +4358,7 @@
43584358
"@executable_path/../Frameworks",
43594359
);
43604360
MACOSX_DEPLOYMENT_TARGET = 13.5;
4361-
MARKETING_VERSION = 25.10.1;
4361+
MARKETING_VERSION = 25.10.2;
43624362
PRODUCT_BUNDLE_IDENTIFIER = com.nicoverbruggen.phpmon.eap;
43634363
PRODUCT_MODULE_NAME = PHP_Monitor;
43644364
PRODUCT_NAME = "$(TARGET_NAME) EAP";

phpmon/Common/PHP/PHP Version/PhpEnvironments.swift

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,39 @@ class PhpEnvironments {
2222
}
2323

2424
/**
25-
Determine which PHP version the `php` formula is aliased to.
25+
Loads the valid HomebrewPackage information.
26+
If invalid, this will prevent PHP Monitor from starting correctly.
2627
*/
27-
@MainActor func determinePhpAlias() async {
28+
func getHomebrewInformation() async {
2829
let brewPhpAlias = await container.shell.pipe("\(container.paths.brew) info php --json").out
2930

30-
self.homebrewPackage = try! JSONDecoder().decode(
31+
// Remove any non-JSON output (progress indicators, etc.) before the actual JSON array
32+
// This is a workaround for https://github.com/homebrew/brew/issues/20978
33+
// Since users may not upgrade Homebrew frequently, this fix will remain
34+
let jsonString = brewPhpAlias
35+
.components(separatedBy: .newlines)
36+
.drop(while: { !$0.trimmingCharacters(in: .whitespaces).hasPrefix("[") })
37+
.joined(separator: "\n")
38+
39+
// Get all packages
40+
let packages = try? JSONDecoder().decode(
3141
[HomebrewPackage].self,
32-
from: brewPhpAlias.data(using: .utf8)!
33-
).first!
42+
from: jsonString.data(using: .utf8)!
43+
)
3444

45+
// But we only need the first one!
46+
guard let package = packages?.first else {
47+
Log.err("Could not determine PHP version due to malformed output.")
48+
return
49+
}
50+
51+
self.homebrewPackage = package
52+
}
53+
54+
/**
55+
Determine which PHP version the `php` formula is aliased to.
56+
*/
57+
func determinePhpAlias() async {
3558
PhpEnvironments.brewPhpAlias = self.homebrewPackage.version
3659
Log.info("[BREW] On your system, the `php` formula means version \(homebrewPackage.version).")
3760

phpmon/Domain/App/Startup.swift

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,7 @@ class Startup {
118118
App.shared.container.paths.optPath
119119
),
120120
descriptionText: "startup.errors.php_opt.desc".localized
121-
)
122-
]),
123-
EnvironmentCheckGroup(name: "valet", condition: { return Valet.installed }, checks: [
121+
),
124122
// =================================================================================
125123
// The PHP binary must exist.
126124
// =================================================================================
@@ -148,6 +146,21 @@ class Startup {
148146
),
149147
descriptionText: "startup.errors.dyld_library.desc".localized
150148
),
149+
// =================================================================================
150+
// Make sure we can get valid output from Homebrew's info command.
151+
// =================================================================================
152+
EnvironmentCheck(
153+
command: { container in
154+
await container.phpEnvs.getHomebrewInformation()
155+
return container.phpEnvs.homebrewPackage == nil
156+
},
157+
name: "`brew info php --json` could parse valid JSON",
158+
titleText: "startup.errors.php_brew_info_invalid.title".localized,
159+
subtitleText: "startup.errors.php_brew_info_invalid.subtitle".localized,
160+
descriptionText: "startup.errors.php_brew_info_invalid.desc".localized
161+
)
162+
]),
163+
EnvironmentCheckGroup(name: "valet", condition: { return Valet.installed }, checks: [
151164
// =================================================================================
152165
// The Valet binary must exist.
153166
// =================================================================================

phpmon/Domain/Menu/MainMenu+Startup.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ extension MainMenu {
3030
When the environment is all clear and the app can run, let's go.
3131
*/
3232
private func onEnvironmentPass() async {
33+
// Load additional preferences
34+
await container.preferences.loadCustomPreferences()
35+
3336
// Determine what the `php` formula is aliased to
3437
await container.phpEnvs.determinePhpAlias()
3538

phpmon/Domain/Preferences/Preferences.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ class Preferences {
2929
if isRunningSwiftUIPreview {
3030
return
3131
}
32-
33-
Task { await loadCustomPreferences() }
3432
}
3533

3634
// MARK: - First Time Run

phpmon/en.lproj/Localizable.strings

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -671,6 +671,11 @@ You can do this by running `composer global update` in your terminal. After that
671671
"startup.errors.php_binary.subtitle" = "You must install PHP via Homebrew. The app will not work correctly until you resolve this issue.";
672672
"startup.errors.php_binary.desc" = "Usually running `brew link php` in your Terminal will resolve this issue.\n\nTo diagnose what is wrong, you can try running `which php` in your Terminal, it should return `%@`.";
673673

674+
// Invalid brew info php output
675+
"startup.errors.php_brew_info_invalid.title" = "Homebrew returned invalid output for `brew info php --json` which requires valid JSON as output.";
676+
"startup.errors.php_brew_info_invalid.subtitle" = "This will prevent PHP Monitor from starting correctly. It's possible that Homebrew is currently in a broken state or some additional logging crept into the output of this command. This is a known issue.";
677+
"startup.errors.php_brew_info_invalid.desc" = "Simply retrying may fix the issue, but you may want to run the command yourself if the issue persists and validate if it's valid JSON. Press OK, and select Retry to try again.";
678+
674679
// PHP not found in /usr/local/opt or /opt/homebrew/opt
675680
"startup.errors.php_opt.title" = "PHP is not correctly installed";
676681
"startup.errors.php_opt.subtitle" = "The PHP alias was not found in `%@`. The app will not work correctly until you resolve this issue.";

0 commit comments

Comments
 (0)