-
-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* develop: ♻️ Change how the active PHP version is switched
- Loading branch information
Showing
2 changed files
with
19 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,14 +28,25 @@ class Actions { | |
|
||
public static func switchToPhpVersion(version: String, availableVersions: [String]) { | ||
availableVersions.forEach { (version) in | ||
// Unlink the current version | ||
Shell.user.run("brew unlink php@\(version)") | ||
// Stop the services | ||
if (version == Constants.LatestPhpVersion) { | ||
Shell.user.run("sudo brew services stop php") | ||
} else { | ||
Shell.user.run("sudo brew services stop php@\(version)") | ||
} | ||
} | ||
if (availableVersions.contains("7.4")) { | ||
Shell.user.run("brew link [email protected]") | ||
if (availableVersions.contains(Constants.LatestPhpVersion)) { | ||
// Use the latest version as a default | ||
Shell.user.run("brew link php@\(Constants.LatestPhpVersion) --overwrite --force") | ||
if (version == Constants.LatestPhpVersion) { | ||
Shell.user.run("valet use php") | ||
// If said version was also requested, all we need to do is start the service | ||
Shell.user.run("sudo brew services start php") | ||
} else { | ||
Shell.user.run("valet use php@\(version)") | ||
// Otherwise, link the correct php version + start the correct service | ||
Shell.user.run("brew link php@\(version) --overwrite --force") | ||
Shell.user.run("sudo brew services start php@\(version)") | ||
} | ||
} | ||
} | ||
|