1
0
mirror of https://github.com/nicoverbruggen/phpmon.git synced 2025-08-08 04:20:07 +02:00

👌 Adjust internal switcher

This commit is contained in:
2022-03-16 18:04:45 +01:00
parent 09a5cf836a
commit 8419ebad10
3 changed files with 21 additions and 21 deletions

View File

@ -30,10 +30,11 @@ class InternalSwitcher: PhpSwitcher {
return site.isolatedPhpVersion!.versionNumber.homebrewVersion
}
var versions: Set<String> = []
// TODO: Do not use isolation if on Valet 2.x
versions = versions.union(isolated)
versions = versions.union([version])
var versions: Set<String> = [version]
if (Valet.enabled(feature: .isolatedSites)) {
versions = versions.union(isolated)
}
let group = DispatchGroup()
@ -57,7 +58,7 @@ class InternalSwitcher: PhpSwitcher {
Log.info("Restarting nginx, just to be sure!")
brew("services restart nginx", sudo: true)
Log.info("The new version(s) has been linked!")
Log.info("The new version(s) have been linked!")
completion()
}
}
@ -66,25 +67,27 @@ class InternalSwitcher: PhpSwitcher {
let formula = (version == PhpEnv.brewPhpVersion) ? "php" : "php@\(version)"
brew("unlink \(formula)")
brew("services stop \(formula)", sudo: true)
Log.perf("Unlinked and stopped services for \(formula)")
Log.info("Unlinked and stopped services for \(formula)")
}
private func startPhpVersion(_ version: String, primary: Bool) {
let formula = (version == PhpEnv.brewPhpVersion) ? "php" : "php@\(version)"
if (primary) {
Log.perf("PHP \(formula) is the primary formula, linking and starting services...")
Log.info("\(formula) is the primary formula, linking and starting services...")
brew("link \(formula) --overwrite --force")
} else {
Log.perf("PHP \(formula) is an isolated PHP version, starting services only...")
Log.info("\(formula) is an isolated PHP version, starting services only...")
}
brew("services start \(formula)", sudo: true)
// TODO: Symlink might not need to be created if Valet 2.x
let socketVersion = version.replacingOccurrences(of: ".", with: "")
Shell.run("ln -sF ~/.config/valet/valet\(socketVersion).sock ~/.config/valet/valet.sock")
Log.perf("Symlinked new socket version.")
if Valet.enabled(feature: .isolatedSites) && primary {
let socketVersion = version.replacingOccurrences(of: ".", with: "")
Shell.run("ln -sF ~/.config/valet/valet\(socketVersion).sock ~/.config/valet/valet.sock")
Log.info("Symlinked new socket version (valet\(socketVersion).sock → valet.sock).")
}
}
}

View File

@ -98,14 +98,15 @@ class Valet {
installed is not recent enough.
*/
public func validateVersion() -> Void {
if version.versionCompare("3.0") == .orderedAscending {
Log.info("This version of Valet does not support isolation yet. Disabling isolation checks.")
self.features.append(.supportForPhp56)
} else {
Log.info("This version of Valet does not support PHP 5.6.")
if Shell.pipe("valet", requiresPath: true).contains("isolate") {
Log.info("This version of Valet supports isolation.")
self.features.append(.isolatedSites)
}
if version.versionCompare("3.0") == .orderedAscending {
self.features.append(.supportForPhp56)
}
if version.versionCompare(Constants.MinimumRecommendedValetVersion) == .orderedAscending {
let version = version
Log.warn("Valet version \(version!) is too old! (recommended: \(Constants.MinimumRecommendedValetVersion))")

View File

@ -310,10 +310,6 @@ You can do this by running `composer global update` in your terminal. After that
"startup.errors.services_json_error.subtitle" = "PHP Monitor usually queries `brew` using the following command to test if the services can be retrieved: `sudo brew services info nginx --json`.\n\nPHP Monitor could not interpret this response.";
"startup.errors.services_json_error.desc" = "This can happen if your Homebrew installation is out of date, in which case Homebrew won't return JSON yet. You can usually fix this by running `brew update`. You can also try running `sudo brew services info nginx --json` in your terminal of choice.";
/// Multiple services active
"startup.errors.services.title" = "Multiple PHP services are active";
"startup.errors.services.desc" = "This can cause php-fpm to serve a more recent version of PHP than the one you'd like to see active. Please terminate all extra PHP processes.\n\nThe easiest solution is to choose the option 'First Aid & Services > Fix My Valet' in the menu bar.\n\nAlternatively, you can fix this manually. You can do this by running `brew services list` and running `sudo brew services stop php@7.3` (and use the version that applies).\n\nPHP Monitor usually handles the starting and stopping of these services, so once the correct version is the only PHP version running you should not have any issues. It is recommended to restart PHP Monitor once you have resolved this issue.\n\nFor more information about this issue, please see the README.md file in the repository on GitHub.";
// SPONSOR ENCOURAGEMENT
"startup.sponsor_encouragement.title" = "If PHP Monitor has been useful to you or your company, please consider leaving a tip.";