Skip to content

Commit cbf5526

Browse files
♻️ Change how the active PHP version is switched
1 parent 1c62a10 commit cbf5526

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

PHP Monitor.xcodeproj/project.pbxproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -365,14 +365,14 @@
365365
CODE_SIGN_IDENTITY = "-";
366366
CODE_SIGN_STYLE = Automatic;
367367
COMBINE_HIDPI_IMAGES = YES;
368-
CURRENT_PROJECT_VERSION = 16;
368+
CURRENT_PROJECT_VERSION = 17;
369369
DEVELOPMENT_TEAM = 8M54J5J787;
370370
INFOPLIST_FILE = phpmon/Info.plist;
371371
LD_RUNPATH_SEARCH_PATHS = (
372372
"$(inherited)",
373373
"@executable_path/../Frameworks",
374374
);
375-
MARKETING_VERSION = 1.6;
375+
MARKETING_VERSION = 1.7;
376376
PRODUCT_BUNDLE_IDENTIFIER = com.nicoverbruggen.phpmon;
377377
PRODUCT_NAME = "$(TARGET_NAME)";
378378
SWIFT_VERSION = 5.0;
@@ -387,14 +387,14 @@
387387
CODE_SIGN_IDENTITY = "-";
388388
CODE_SIGN_STYLE = Automatic;
389389
COMBINE_HIDPI_IMAGES = YES;
390-
CURRENT_PROJECT_VERSION = 16;
390+
CURRENT_PROJECT_VERSION = 17;
391391
DEVELOPMENT_TEAM = 8M54J5J787;
392392
INFOPLIST_FILE = phpmon/Info.plist;
393393
LD_RUNPATH_SEARCH_PATHS = (
394394
"$(inherited)",
395395
"@executable_path/../Frameworks",
396396
);
397-
MARKETING_VERSION = 1.6;
397+
MARKETING_VERSION = 1.7;
398398
PRODUCT_BUNDLE_IDENTIFIER = com.nicoverbruggen.phpmon;
399399
PRODUCT_NAME = "$(TARGET_NAME)";
400400
SWIFT_VERSION = 5.0;

phpmon/Classes/Commands/Actions.swift

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,25 @@ class Actions {
2828

2929
public static func switchToPhpVersion(version: String, availableVersions: [String]) {
3030
availableVersions.forEach { (version) in
31+
// Unlink the current version
3132
Shell.user.run("brew unlink php@\(version)")
33+
// Stop the services
34+
if (version == Constants.LatestPhpVersion) {
35+
Shell.user.run("sudo brew services stop php")
36+
} else {
37+
Shell.user.run("sudo brew services stop php@\(version)")
38+
}
3239
}
33-
if (availableVersions.contains("7.4")) {
34-
Shell.user.run("brew link [email protected]")
40+
if (availableVersions.contains(Constants.LatestPhpVersion)) {
41+
// Use the latest version as a default
42+
Shell.user.run("brew link php@\(Constants.LatestPhpVersion) --overwrite --force")
3543
if (version == Constants.LatestPhpVersion) {
36-
Shell.user.run("valet use php")
44+
// If said version was also requested, all we need to do is start the service
45+
Shell.user.run("sudo brew services start php")
3746
} else {
38-
Shell.user.run("valet use php@\(version)")
47+
// Otherwise, link the correct php version + start the correct service
48+
Shell.user.run("brew link php@\(version) --overwrite --force")
49+
Shell.user.run("sudo brew services start php@\(version)")
3950
}
4051
}
4152
}

0 commit comments

Comments
 (0)