1
0
mirror of https://github.com/nicoverbruggen/phpmon.git synced 2026-03-30 08:20:09 +02:00

🔀 Merge branch 'develop'

* develop:
  ♻️ Change how the active PHP version is switched
This commit is contained in:
2020-02-20 11:48:54 +01:00
2 changed files with 20 additions and 9 deletions

View File

@@ -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)")
}
if (availableVersions.contains("7.4")) {
Shell.user.run("brew link php@7.4")
// Stop the services
if (version == Constants.LatestPhpVersion) {
Shell.user.run("valet use php")
Shell.user.run("sudo brew services stop php")
} else {
Shell.user.run("valet use php@\(version)")
Shell.user.run("sudo brew services stop php@\(version)")
}
}
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) {
// If said version was also requested, all we need to do is start the service
Shell.user.run("sudo brew services start php")
} else {
// 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)")
}
}
}