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:
@ -30,10 +30,11 @@ class InternalSwitcher: PhpSwitcher {
|
|||||||
return site.isolatedPhpVersion!.versionNumber.homebrewVersion
|
return site.isolatedPhpVersion!.versionNumber.homebrewVersion
|
||||||
}
|
}
|
||||||
|
|
||||||
var versions: Set<String> = []
|
var versions: Set<String> = [version]
|
||||||
// TODO: Do not use isolation if on Valet 2.x
|
|
||||||
versions = versions.union(isolated)
|
if (Valet.enabled(feature: .isolatedSites)) {
|
||||||
versions = versions.union([version])
|
versions = versions.union(isolated)
|
||||||
|
}
|
||||||
|
|
||||||
let group = DispatchGroup()
|
let group = DispatchGroup()
|
||||||
|
|
||||||
@ -57,7 +58,7 @@ class InternalSwitcher: PhpSwitcher {
|
|||||||
Log.info("Restarting nginx, just to be sure!")
|
Log.info("Restarting nginx, just to be sure!")
|
||||||
brew("services restart nginx", sudo: true)
|
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()
|
completion()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -66,25 +67,27 @@ class InternalSwitcher: PhpSwitcher {
|
|||||||
let formula = (version == PhpEnv.brewPhpVersion) ? "php" : "php@\(version)"
|
let formula = (version == PhpEnv.brewPhpVersion) ? "php" : "php@\(version)"
|
||||||
brew("unlink \(formula)")
|
brew("unlink \(formula)")
|
||||||
brew("services stop \(formula)", sudo: true)
|
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) {
|
private func startPhpVersion(_ version: String, primary: Bool) {
|
||||||
let formula = (version == PhpEnv.brewPhpVersion) ? "php" : "php@\(version)"
|
let formula = (version == PhpEnv.brewPhpVersion) ? "php" : "php@\(version)"
|
||||||
|
|
||||||
if (primary) {
|
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")
|
brew("link \(formula) --overwrite --force")
|
||||||
} else {
|
} 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)
|
brew("services start \(formula)", sudo: true)
|
||||||
|
|
||||||
// TODO: Symlink might not need to be created if Valet 2.x
|
if Valet.enabled(feature: .isolatedSites) && primary {
|
||||||
let socketVersion = version.replacingOccurrences(of: ".", with: "")
|
let socketVersion = version.replacingOccurrences(of: ".", with: "")
|
||||||
Shell.run("ln -sF ~/.config/valet/valet\(socketVersion).sock ~/.config/valet/valet.sock")
|
Shell.run("ln -sF ~/.config/valet/valet\(socketVersion).sock ~/.config/valet/valet.sock")
|
||||||
Log.perf("Symlinked new socket version.")
|
Log.info("Symlinked new socket version (valet\(socketVersion).sock → valet.sock).")
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -98,14 +98,15 @@ class Valet {
|
|||||||
installed is not recent enough.
|
installed is not recent enough.
|
||||||
*/
|
*/
|
||||||
public func validateVersion() -> Void {
|
public func validateVersion() -> Void {
|
||||||
if version.versionCompare("3.0") == .orderedAscending {
|
if Shell.pipe("valet", requiresPath: true).contains("isolate") {
|
||||||
Log.info("This version of Valet does not support isolation yet. Disabling isolation checks.")
|
Log.info("This version of Valet supports isolation.")
|
||||||
self.features.append(.supportForPhp56)
|
|
||||||
} else {
|
|
||||||
Log.info("This version of Valet does not support PHP 5.6.")
|
|
||||||
self.features.append(.isolatedSites)
|
self.features.append(.isolatedSites)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if version.versionCompare("3.0") == .orderedAscending {
|
||||||
|
self.features.append(.supportForPhp56)
|
||||||
|
}
|
||||||
|
|
||||||
if version.versionCompare(Constants.MinimumRecommendedValetVersion) == .orderedAscending {
|
if version.versionCompare(Constants.MinimumRecommendedValetVersion) == .orderedAscending {
|
||||||
let version = version
|
let version = version
|
||||||
Log.warn("Valet version \(version!) is too old! (recommended: \(Constants.MinimumRecommendedValetVersion))")
|
Log.warn("Valet version \(version!) is too old! (recommended: \(Constants.MinimumRecommendedValetVersion))")
|
||||||
|
@ -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.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.";
|
"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
|
// SPONSOR ENCOURAGEMENT
|
||||||
|
|
||||||
"startup.sponsor_encouragement.title" = "If PHP Monitor has been useful to you or your company, please consider leaving a tip.";
|
"startup.sponsor_encouragement.title" = "If PHP Monitor has been useful to you or your company, please consider leaving a tip.";
|
||||||
|
Reference in New Issue
Block a user