mirror of
https://github.com/nicoverbruggen/phpmon.git
synced 2025-08-08 04:20:07 +02:00
♻️ Rename PhpEnv to PhpEnvironments
This commit is contained in:
@ -72,8 +72,8 @@
|
|||||||
C40B24F427A310830018C7D2 /* StatusMenu.swift in Sources */ = {isa = PBXBuildFile; fileRef = C47331A1247093B7009A0597 /* StatusMenu.swift */; };
|
C40B24F427A310830018C7D2 /* StatusMenu.swift in Sources */ = {isa = PBXBuildFile; fileRef = C47331A1247093B7009A0597 /* StatusMenu.swift */; };
|
||||||
C40C5C9C2846A40600E28255 /* Preset.swift in Sources */ = {isa = PBXBuildFile; fileRef = C40C5C9B2846A40600E28255 /* Preset.swift */; };
|
C40C5C9C2846A40600E28255 /* Preset.swift in Sources */ = {isa = PBXBuildFile; fileRef = C40C5C9B2846A40600E28255 /* Preset.swift */; };
|
||||||
C40C5C9D2846A40600E28255 /* Preset.swift in Sources */ = {isa = PBXBuildFile; fileRef = C40C5C9B2846A40600E28255 /* Preset.swift */; };
|
C40C5C9D2846A40600E28255 /* Preset.swift in Sources */ = {isa = PBXBuildFile; fileRef = C40C5C9B2846A40600E28255 /* Preset.swift */; };
|
||||||
C40C7F1E2772136000DDDCDC /* PhpEnv.swift in Sources */ = {isa = PBXBuildFile; fileRef = C40C7F1D2772136000DDDCDC /* PhpEnv.swift */; };
|
C40C7F1E2772136000DDDCDC /* PhpEnvironments.swift in Sources */ = {isa = PBXBuildFile; fileRef = C40C7F1D2772136000DDDCDC /* PhpEnvironments.swift */; };
|
||||||
C40C7F1F2772136000DDDCDC /* PhpEnv.swift in Sources */ = {isa = PBXBuildFile; fileRef = C40C7F1D2772136000DDDCDC /* PhpEnv.swift */; };
|
C40C7F1F2772136000DDDCDC /* PhpEnvironments.swift in Sources */ = {isa = PBXBuildFile; fileRef = C40C7F1D2772136000DDDCDC /* PhpEnvironments.swift */; };
|
||||||
C40C7F2827721FF600DDDCDC /* Valet+Alerts.swift in Sources */ = {isa = PBXBuildFile; fileRef = C40C7F2727721FF600DDDCDC /* Valet+Alerts.swift */; };
|
C40C7F2827721FF600DDDCDC /* Valet+Alerts.swift in Sources */ = {isa = PBXBuildFile; fileRef = C40C7F2727721FF600DDDCDC /* Valet+Alerts.swift */; };
|
||||||
C40C7F2927721FF600DDDCDC /* Valet+Alerts.swift in Sources */ = {isa = PBXBuildFile; fileRef = C40C7F2727721FF600DDDCDC /* Valet+Alerts.swift */; };
|
C40C7F2927721FF600DDDCDC /* Valet+Alerts.swift in Sources */ = {isa = PBXBuildFile; fileRef = C40C7F2727721FF600DDDCDC /* Valet+Alerts.swift */; };
|
||||||
C40C7F3027722E8D00DDDCDC /* Logger.swift in Sources */ = {isa = PBXBuildFile; fileRef = C40C7F2F27722E8D00DDDCDC /* Logger.swift */; };
|
C40C7F3027722E8D00DDDCDC /* Logger.swift in Sources */ = {isa = PBXBuildFile; fileRef = C40C7F2F27722E8D00DDDCDC /* Logger.swift */; };
|
||||||
@ -288,10 +288,10 @@
|
|||||||
C471E7EF28F9BAC30021E251 /* Actions.swift in Sources */ = {isa = PBXBuildFile; fileRef = C415D3B62770F294005EF286 /* Actions.swift */; };
|
C471E7EF28F9BAC30021E251 /* Actions.swift in Sources */ = {isa = PBXBuildFile; fileRef = C415D3B62770F294005EF286 /* Actions.swift */; };
|
||||||
C471E7F028F9BAC30021E251 /* Paths.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4B5853B2770FE3900DA4FBE /* Paths.swift */; };
|
C471E7F028F9BAC30021E251 /* Paths.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4B5853B2770FE3900DA4FBE /* Paths.swift */; };
|
||||||
C471E7F128F9BAC70021E251 /* VersionNumber.swift in Sources */ = {isa = PBXBuildFile; fileRef = C48D6C6F279CD2AC00F26D7E /* VersionNumber.swift */; };
|
C471E7F128F9BAC70021E251 /* VersionNumber.swift in Sources */ = {isa = PBXBuildFile; fileRef = C48D6C6F279CD2AC00F26D7E /* VersionNumber.swift */; };
|
||||||
C471E7F228F9BAC70021E251 /* PhpEnv.swift in Sources */ = {isa = PBXBuildFile; fileRef = C40C7F1D2772136000DDDCDC /* PhpEnv.swift */; };
|
C471E7F228F9BAC70021E251 /* PhpEnvironments.swift in Sources */ = {isa = PBXBuildFile; fileRef = C40C7F1D2772136000DDDCDC /* PhpEnvironments.swift */; };
|
||||||
C471E7F328F9BAC70021E251 /* PhpHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4D936C827E3EB6100BD69FE /* PhpHelper.swift */; };
|
C471E7F328F9BAC70021E251 /* PhpHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4D936C827E3EB6100BD69FE /* PhpHelper.swift */; };
|
||||||
C471E7F428F9BAC80021E251 /* VersionNumber.swift in Sources */ = {isa = PBXBuildFile; fileRef = C48D6C6F279CD2AC00F26D7E /* VersionNumber.swift */; };
|
C471E7F428F9BAC80021E251 /* VersionNumber.swift in Sources */ = {isa = PBXBuildFile; fileRef = C48D6C6F279CD2AC00F26D7E /* VersionNumber.swift */; };
|
||||||
C471E7F528F9BAC80021E251 /* PhpEnv.swift in Sources */ = {isa = PBXBuildFile; fileRef = C40C7F1D2772136000DDDCDC /* PhpEnv.swift */; };
|
C471E7F528F9BAC80021E251 /* PhpEnvironments.swift in Sources */ = {isa = PBXBuildFile; fileRef = C40C7F1D2772136000DDDCDC /* PhpEnvironments.swift */; };
|
||||||
C471E7F628F9BAC80021E251 /* PhpHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4D936C827E3EB6100BD69FE /* PhpHelper.swift */; };
|
C471E7F628F9BAC80021E251 /* PhpHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4D936C827E3EB6100BD69FE /* PhpHelper.swift */; };
|
||||||
C471E7F728F9BACB0021E251 /* PhpSwitcher.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4D9ADBE277610E1007277F4 /* PhpSwitcher.swift */; };
|
C471E7F728F9BACB0021E251 /* PhpSwitcher.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4D9ADBE277610E1007277F4 /* PhpSwitcher.swift */; };
|
||||||
C471E7F828F9BACB0021E251 /* InternalSwitcher.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4D9ADC7277611A0007277F4 /* InternalSwitcher.swift */; };
|
C471E7F828F9BACB0021E251 /* InternalSwitcher.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4D9ADC7277611A0007277F4 /* InternalSwitcher.swift */; };
|
||||||
@ -876,7 +876,7 @@
|
|||||||
C40934A6298EEB8700D25014 /* phpmon-dev.rb */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.ruby; path = "phpmon-dev.rb"; sourceTree = "<group>"; };
|
C40934A6298EEB8700D25014 /* phpmon-dev.rb */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.ruby; path = "phpmon-dev.rb"; sourceTree = "<group>"; };
|
||||||
C40934AA298EEDA900D25014 /* CaskFileParserTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CaskFileParserTest.swift; sourceTree = "<group>"; };
|
C40934AA298EEDA900D25014 /* CaskFileParserTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CaskFileParserTest.swift; sourceTree = "<group>"; };
|
||||||
C40C5C9B2846A40600E28255 /* Preset.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Preset.swift; sourceTree = "<group>"; };
|
C40C5C9B2846A40600E28255 /* Preset.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Preset.swift; sourceTree = "<group>"; };
|
||||||
C40C7F1D2772136000DDDCDC /* PhpEnv.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PhpEnv.swift; sourceTree = "<group>"; };
|
C40C7F1D2772136000DDDCDC /* PhpEnvironments.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PhpEnvironments.swift; sourceTree = "<group>"; };
|
||||||
C40C7F2727721FF600DDDCDC /* Valet+Alerts.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Valet+Alerts.swift"; sourceTree = "<group>"; };
|
C40C7F2727721FF600DDDCDC /* Valet+Alerts.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Valet+Alerts.swift"; sourceTree = "<group>"; };
|
||||||
C40C7F2F27722E8D00DDDCDC /* Logger.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Logger.swift; sourceTree = "<group>"; };
|
C40C7F2F27722E8D00DDDCDC /* Logger.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Logger.swift; sourceTree = "<group>"; };
|
||||||
C40D72592A018ACC0054A067 /* PhpFormulaeStatus.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PhpFormulaeStatus.swift; sourceTree = "<group>"; };
|
C40D72592A018ACC0054A067 /* PhpFormulaeStatus.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PhpFormulaeStatus.swift; sourceTree = "<group>"; };
|
||||||
@ -1654,7 +1654,7 @@
|
|||||||
children = (
|
children = (
|
||||||
C48D6C6F279CD2AC00F26D7E /* VersionNumber.swift */,
|
C48D6C6F279CD2AC00F26D7E /* VersionNumber.swift */,
|
||||||
C4CE7F9529683B43000102CF /* PhpVersionNumberCollection.swift */,
|
C4CE7F9529683B43000102CF /* PhpVersionNumberCollection.swift */,
|
||||||
C40C7F1D2772136000DDDCDC /* PhpEnv.swift */,
|
C40C7F1D2772136000DDDCDC /* PhpEnvironments.swift */,
|
||||||
C4D936C827E3EB6100BD69FE /* PhpHelper.swift */,
|
C4D936C827E3EB6100BD69FE /* PhpHelper.swift */,
|
||||||
);
|
);
|
||||||
path = "PHP Version";
|
path = "PHP Version";
|
||||||
@ -2427,7 +2427,7 @@
|
|||||||
C4D3660B29113F20006BD146 /* System.swift in Sources */,
|
C4D3660B29113F20006BD146 /* System.swift in Sources */,
|
||||||
C4D36601291132B7006BD146 /* ValetScanners.swift in Sources */,
|
C4D36601291132B7006BD146 /* ValetScanners.swift in Sources */,
|
||||||
C4EED88927A48778006D7272 /* InterAppHandler.swift in Sources */,
|
C4EED88927A48778006D7272 /* InterAppHandler.swift in Sources */,
|
||||||
C40C7F1E2772136000DDDCDC /* PhpEnv.swift in Sources */,
|
C40C7F1E2772136000DDDCDC /* PhpEnvironments.swift in Sources */,
|
||||||
C4B79EB629CA387F00A483EE /* BrewFormulaeHandler.swift in Sources */,
|
C4B79EB629CA387F00A483EE /* BrewFormulaeHandler.swift in Sources */,
|
||||||
C476FF9822B0DD830098105B /* Alert.swift in Sources */,
|
C476FF9822B0DD830098105B /* Alert.swift in Sources */,
|
||||||
C474B00624C0E98C00066A22 /* LocalNotification.swift in Sources */,
|
C474B00624C0E98C00066A22 /* LocalNotification.swift in Sources */,
|
||||||
@ -2626,7 +2626,7 @@
|
|||||||
C490E3B929BCA368006D2DE6 /* App+BrewWatch.swift in Sources */,
|
C490E3B929BCA368006D2DE6 /* App+BrewWatch.swift in Sources */,
|
||||||
C471E7FF28F9BAD10021E251 /* Xdebug.swift in Sources */,
|
C471E7FF28F9BAD10021E251 /* Xdebug.swift in Sources */,
|
||||||
C409349F298EE8E900D25014 /* AppUpdater.swift in Sources */,
|
C409349F298EE8E900D25014 /* AppUpdater.swift in Sources */,
|
||||||
C471E7F228F9BAC70021E251 /* PhpEnv.swift in Sources */,
|
C471E7F228F9BAC70021E251 /* PhpEnvironments.swift in Sources */,
|
||||||
C471E7E628F9BAC20021E251 /* Process.swift in Sources */,
|
C471E7E628F9BAC20021E251 /* Process.swift in Sources */,
|
||||||
C471E81928F9BAE80021E251 /* NSMenuItemExtension.swift in Sources */,
|
C471E81928F9BAE80021E251 /* NSMenuItemExtension.swift in Sources */,
|
||||||
C45B914B295607F400F4EC78 /* Service.swift in Sources */,
|
C45B914B295607F400F4EC78 /* Service.swift in Sources */,
|
||||||
@ -2824,7 +2824,7 @@
|
|||||||
C44E985F29B23EBF0059F773 /* UpdateCheckTest.swift in Sources */,
|
C44E985F29B23EBF0059F773 /* UpdateCheckTest.swift in Sources */,
|
||||||
C471E7D228F9BA630021E251 /* ActiveFileSystem.swift in Sources */,
|
C471E7D228F9BA630021E251 /* ActiveFileSystem.swift in Sources */,
|
||||||
C471E80028F9BAD10021E251 /* Xdebug.swift in Sources */,
|
C471E80028F9BAD10021E251 /* Xdebug.swift in Sources */,
|
||||||
C471E7F528F9BAC80021E251 /* PhpEnv.swift in Sources */,
|
C471E7F528F9BAC80021E251 /* PhpEnvironments.swift in Sources */,
|
||||||
C471E7ED28F9BAC30021E251 /* Process.swift in Sources */,
|
C471E7ED28F9BAC30021E251 /* Process.swift in Sources */,
|
||||||
C471E81128F9BAE80021E251 /* NSMenuItemExtension.swift in Sources */,
|
C471E81128F9BAE80021E251 /* NSMenuItemExtension.swift in Sources */,
|
||||||
C471E7CC28F9BA5B0021E251 /* TestableShell.swift in Sources */,
|
C471E7CC28F9BA5B0021E251 /* TestableShell.swift in Sources */,
|
||||||
@ -3055,7 +3055,7 @@
|
|||||||
C43BCD4529FBEF40001547BC /* InstallAndUpgradeCommand.swift in Sources */,
|
C43BCD4529FBEF40001547BC /* InstallAndUpgradeCommand.swift in Sources */,
|
||||||
C4551657297AED18009B8466 /* ValetRcTest.swift in Sources */,
|
C4551657297AED18009B8466 /* ValetRcTest.swift in Sources */,
|
||||||
C464ADAD275A7A3F003FCD53 /* DomainListWindowController.swift in Sources */,
|
C464ADAD275A7A3F003FCD53 /* DomainListWindowController.swift in Sources */,
|
||||||
C40C7F1F2772136000DDDCDC /* PhpEnv.swift in Sources */,
|
C40C7F1F2772136000DDDCDC /* PhpEnvironments.swift in Sources */,
|
||||||
C464ADB0275A7A6A003FCD53 /* DomainListVC.swift in Sources */,
|
C464ADB0275A7A6A003FCD53 /* DomainListVC.swift in Sources */,
|
||||||
C43A8A1A25D9CD1000591B77 /* Utility.swift in Sources */,
|
C43A8A1A25D9CD1000591B77 /* Utility.swift in Sources */,
|
||||||
C46EBC4B28DB966A007ACC74 /* TestableShell.swift in Sources */,
|
C46EBC4B28DB966A007ACC74 /* TestableShell.swift in Sources */,
|
||||||
|
@ -47,8 +47,8 @@ class Actions {
|
|||||||
"chown -R \(Paths.whoami):admin \(Paths.cellarPath)/\(HomebrewFormulae.dnsmasq)"
|
"chown -R \(Paths.whoami):admin \(Paths.cellarPath)/\(HomebrewFormulae.dnsmasq)"
|
||||||
]
|
]
|
||||||
|
|
||||||
PhpEnv.shared.availablePhpVersions.forEach { version in
|
PhpEnvironments.shared.availablePhpVersions.forEach { version in
|
||||||
let formula = version == PhpEnv.brewPhpAlias
|
let formula = version == PhpEnvironments.brewPhpAlias
|
||||||
? "php"
|
? "php"
|
||||||
: "php@\(version)"
|
: "php@\(version)"
|
||||||
servicesCommands.append("\(Paths.brew) services stop \(formula)")
|
servicesCommands.append("\(Paths.brew) services stop \(formula)")
|
||||||
@ -125,7 +125,7 @@ class Actions {
|
|||||||
extensions and/or run `composer global update`.
|
extensions and/or run `composer global update`.
|
||||||
*/
|
*/
|
||||||
public static func fixMyValet() async {
|
public static func fixMyValet() async {
|
||||||
await InternalSwitcher().performSwitch(to: PhpEnv.brewPhpAlias)
|
await InternalSwitcher().performSwitch(to: PhpEnvironments.brewPhpAlias)
|
||||||
await brew("services restart \(HomebrewFormulae.dnsmasq)", sudo: HomebrewFormulae.dnsmasq.elevated)
|
await brew("services restart \(HomebrewFormulae.dnsmasq)", sudo: HomebrewFormulae.dnsmasq.elevated)
|
||||||
await brew("services restart \(HomebrewFormulae.php)", sudo: HomebrewFormulae.php.elevated)
|
await brew("services restart \(HomebrewFormulae.php)", sudo: HomebrewFormulae.php.elevated)
|
||||||
await brew("services restart \(HomebrewFormulae.nginx)", sudo: HomebrewFormulae.nginx.elevated)
|
await brew("services restart \(HomebrewFormulae.nginx)", sudo: HomebrewFormulae.nginx.elevated)
|
||||||
|
@ -10,11 +10,11 @@ import Foundation
|
|||||||
|
|
||||||
struct HomebrewFormulae {
|
struct HomebrewFormulae {
|
||||||
static var php: HomebrewFormula {
|
static var php: HomebrewFormula {
|
||||||
if PhpEnv.shared.homebrewPackage == nil {
|
if PhpEnvironments.shared.homebrewPackage == nil {
|
||||||
return HomebrewFormula("php", elevated: true)
|
return HomebrewFormula("php", elevated: true)
|
||||||
}
|
}
|
||||||
|
|
||||||
guard let install = PhpEnv.phpInstall else {
|
guard let install = PhpEnvironments.phpInstall else {
|
||||||
return HomebrewFormula("php", elevated: true)
|
return HomebrewFormula("php", elevated: true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ class ActivePhpInstallation {
|
|||||||
// MARK: - Computed
|
// MARK: - Computed
|
||||||
|
|
||||||
var formula: String {
|
var formula: String {
|
||||||
return (version.short == PhpEnv.brewPhpAlias) ? "php" : "php@\(version.short)"
|
return (version.short == PhpEnvironments.brewPhpAlias) ? "php" : "php@\(version.short)"
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - Initializer
|
// MARK: - Initializer
|
||||||
|
@ -12,11 +12,11 @@ import Cocoa
|
|||||||
class Xdebug {
|
class Xdebug {
|
||||||
|
|
||||||
public static var enabled: Bool {
|
public static var enabled: Bool {
|
||||||
return PhpEnv.shared.getConfigFile(forKey: "xdebug.mode") != nil
|
return PhpEnvironments.shared.getConfigFile(forKey: "xdebug.mode") != nil
|
||||||
}
|
}
|
||||||
|
|
||||||
public static var activeModes: [String] {
|
public static var activeModes: [String] {
|
||||||
guard let file = PhpEnv.shared.getConfigFile(forKey: "xdebug.mode") else {
|
guard let file = PhpEnvironments.shared.getConfigFile(forKey: "xdebug.mode") else {
|
||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// PhpSwitcher.swift
|
// PhpEnvironments.swift
|
||||||
// PHP Monitor
|
// PHP Monitor
|
||||||
//
|
//
|
||||||
// Created by Nico Verbruggen on 21/12/2021.
|
// Created by Nico Verbruggen on 21/12/2021.
|
||||||
@ -8,18 +8,27 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
class PhpEnv {
|
class PhpEnvironments {
|
||||||
|
|
||||||
// MARK: - Initializer
|
// MARK: - Initializer
|
||||||
|
|
||||||
|
/**
|
||||||
|
|
||||||
|
*/
|
||||||
init() {
|
init() {
|
||||||
self.currentInstall = ActivePhpInstallation.load()
|
self.currentInstall = ActivePhpInstallation.load()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Creates the shared instance. Called when starting the app.
|
||||||
|
*/
|
||||||
static func prepare() {
|
static func prepare() {
|
||||||
_ = Self.shared
|
_ = Self.shared
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Determine which PHP version the `php` formula is aliased to.
|
||||||
|
*/
|
||||||
func determinePhpAlias() async {
|
func determinePhpAlias() async {
|
||||||
let brewPhpAlias = await Shell.pipe("\(Paths.brew) info php --json").out
|
let brewPhpAlias = await Shell.pipe("\(Paths.brew) info php --json").out
|
||||||
|
|
||||||
@ -36,8 +45,8 @@ class PhpEnv {
|
|||||||
/** The delegate that is informed of updates. */
|
/** The delegate that is informed of updates. */
|
||||||
weak var delegate: PhpSwitcherDelegate?
|
weak var delegate: PhpSwitcherDelegate?
|
||||||
|
|
||||||
/** The static app instance. Accessible at any time. */
|
/** The static instance. Accessible at any time. */
|
||||||
static let shared = PhpEnv()
|
static let shared = PhpEnvironments()
|
||||||
|
|
||||||
/** Whether the switcher is busy performing any actions. */
|
/** Whether the switcher is busy performing any actions. */
|
||||||
var isBusy: Bool = false {
|
var isBusy: Bool = false {
|
||||||
@ -71,9 +80,9 @@ class PhpEnv {
|
|||||||
As such, we take that information from Homebrew.
|
As such, we take that information from Homebrew.
|
||||||
*/
|
*/
|
||||||
static var brewPhpAlias: String {
|
static var brewPhpAlias: String {
|
||||||
if PhpEnv.shared.homebrewPackage == nil { return "8.2" }
|
if PhpEnvironments.shared.homebrewPackage == nil { return "8.2" }
|
||||||
|
|
||||||
return PhpEnv.shared.homebrewPackage.version
|
return PhpEnvironments.shared.homebrewPackage.version
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -90,16 +99,30 @@ class PhpEnv {
|
|||||||
|
|
||||||
// MARK: - Methods
|
// MARK: - Methods
|
||||||
|
|
||||||
|
/**
|
||||||
|
The switcher that is currently in use.
|
||||||
|
This was originally added so the Internal and Valet switcher could be swapped out,
|
||||||
|
but currently this is no longer needed.
|
||||||
|
*/
|
||||||
public static var switcher: PhpSwitcher {
|
public static var switcher: PhpSwitcher {
|
||||||
return InternalSwitcher()
|
return InternalSwitcher()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Alias that detects which versions of PHP are installed.
|
||||||
|
See also: `detectPhpVersions()`. Please note that this method
|
||||||
|
does *not* return the set of PHP versions that are supported.
|
||||||
|
*/
|
||||||
public static func detectPhpVersions() async {
|
public static func detectPhpVersions() async {
|
||||||
_ = await Self.shared.detectPhpVersions()
|
_ = await Self.shared.detectPhpVersions()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Detects which versions of PHP are installed.
|
Detects which versions of PHP are installed.
|
||||||
|
This step also detects which versions of PHP are incompatible with the current version of Valet.
|
||||||
|
If a PHP installation is currently broken, that will also be reflected.
|
||||||
|
|
||||||
|
Returns a `Set<String>` of installations that are considered valid.
|
||||||
*/
|
*/
|
||||||
public func detectPhpVersions() async -> Set<String> {
|
public func detectPhpVersions() async -> Set<String> {
|
||||||
let files = await Shell.pipe("ls \(Paths.optPath) | grep php@").out
|
let files = await Shell.pipe("ls \(Paths.optPath) | grep php@").out
|
||||||
@ -184,6 +207,10 @@ class PhpEnv {
|
|||||||
return output
|
return output
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Returns a list of `VersionNumber` instances based on the available PHP versions
|
||||||
|
that are valid to switch to for a given constraint.
|
||||||
|
*/
|
||||||
public func validVersions(for constraint: String) -> [VersionNumber] {
|
public func validVersions(for constraint: String) -> [VersionNumber] {
|
||||||
constraint.split(separator: "|").flatMap {
|
constraint.split(separator: "|").flatMap {
|
||||||
return PhpVersionNumberCollection
|
return PhpVersionNumberCollection
|
||||||
@ -196,7 +223,7 @@ class PhpEnv {
|
|||||||
Validates whether the currently running version matches the provided version.
|
Validates whether the currently running version matches the provided version.
|
||||||
*/
|
*/
|
||||||
public func validate(_ version: String) -> Bool {
|
public func validate(_ version: String) -> Bool {
|
||||||
guard let install = PhpEnv.phpInstall else {
|
guard let install = PhpEnvironments.phpInstall else {
|
||||||
Log.info("It appears as if no PHP installation is currently active.")
|
Log.info("It appears as if no PHP installation is currently active.")
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@ -217,7 +244,7 @@ class PhpEnv {
|
|||||||
You can then use the configuration file instance to change values.
|
You can then use the configuration file instance to change values.
|
||||||
*/
|
*/
|
||||||
public func getConfigFile(forKey key: String) -> PhpConfigurationFile? {
|
public func getConfigFile(forKey key: String) -> PhpConfigurationFile? {
|
||||||
guard let install = PhpEnv.phpInstall else {
|
guard let install = PhpEnvironments.phpInstall else {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
@ -25,7 +25,7 @@ class InternalSwitcher: PhpSwitcher {
|
|||||||
let versions = getVersionsToBeHandled(version)
|
let versions = getVersionsToBeHandled(version)
|
||||||
|
|
||||||
await withTaskGroup(of: String.self, body: { group in
|
await withTaskGroup(of: String.self, body: { group in
|
||||||
for available in PhpEnv.shared.availablePhpVersions {
|
for available in PhpEnvironments.shared.availablePhpVersions {
|
||||||
group.addTask {
|
group.addTask {
|
||||||
await self.unlinkAndStopPhpVersion(available)
|
await self.unlinkAndStopPhpVersion(available)
|
||||||
return available
|
return available
|
||||||
@ -76,7 +76,7 @@ class InternalSwitcher: PhpSwitcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func unlinkAndStopPhpVersion(_ version: String) async {
|
func unlinkAndStopPhpVersion(_ version: String) async {
|
||||||
let formula = (version == PhpEnv.brewPhpAlias) ? "php" : "php@\(version)"
|
let formula = (version == PhpEnvironments.brewPhpAlias) ? "php" : "php@\(version)"
|
||||||
await brew("unlink \(formula)")
|
await brew("unlink \(formula)")
|
||||||
|
|
||||||
if Valet.installed {
|
if Valet.installed {
|
||||||
@ -88,7 +88,7 @@ class InternalSwitcher: PhpSwitcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func linkAndStartPhpVersion(_ version: String, primary: Bool) async {
|
func linkAndStartPhpVersion(_ version: String, primary: Bool) async {
|
||||||
let formula = (version == PhpEnv.brewPhpAlias) ? "php" : "php@\(version)"
|
let formula = (version == PhpEnvironments.brewPhpAlias) ? "php" : "php@\(version)"
|
||||||
|
|
||||||
if primary {
|
if primary {
|
||||||
Log.info("\(formula) is the primary formula, linking...")
|
Log.info("\(formula) is the primary formula, linking...")
|
||||||
|
@ -44,11 +44,11 @@ class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCenterDele
|
|||||||
let brew: Brew
|
let brew: Brew
|
||||||
|
|
||||||
/**
|
/**
|
||||||
The PhpEnv singleton that handles PHP version
|
The PhpEnvironments singleton that handles PHP version
|
||||||
detection, as well as switching. It is initialized
|
detection, as well as switching. It is initialized
|
||||||
when the app is ready and passed all checks.
|
when the app is ready and passed all checks.
|
||||||
*/
|
*/
|
||||||
var phpEnvironment: PhpEnv! = nil
|
var phpEnvironments: PhpEnvironments! = nil
|
||||||
|
|
||||||
/**
|
/**
|
||||||
The logger is responsible for different levels of logging.
|
The logger is responsible for different levels of logging.
|
||||||
@ -98,7 +98,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCenterDele
|
|||||||
}
|
}
|
||||||
|
|
||||||
func initializeSwitcher() {
|
func initializeSwitcher() {
|
||||||
self.phpEnvironment = PhpEnv.shared
|
self.phpEnvironments = PhpEnvironments.shared
|
||||||
}
|
}
|
||||||
|
|
||||||
static func initializeTestingProfile(_ path: String) {
|
static func initializeTestingProfile(_ path: String) {
|
||||||
|
@ -59,11 +59,11 @@ class DomainListPhpCell: NSTableCellView, DomainListCellProtocol {
|
|||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
|
|
||||||
guard let install = PhpEnv.phpInstall else {
|
guard let install = PhpEnvironments.phpInstall else {
|
||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
|
|
||||||
return PhpEnv.shared.validVersions(for: site.preferredPhpVersion).filter({ version in
|
return PhpEnvironments.shared.validVersions(for: site.preferredPhpVersion).filter({ version in
|
||||||
version.short != install.version.short
|
version.short != install.version.short
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -105,7 +105,7 @@ extension DomainListVC {
|
|||||||
private func addIsolate(to menu: NSMenu, with site: ValetSite) {
|
private func addIsolate(to menu: NSMenu, with site: ValetSite) {
|
||||||
var items: [NSMenuItem] = []
|
var items: [NSMenuItem] = []
|
||||||
|
|
||||||
for version in PhpEnv.shared.availablePhpVersions.reversed() {
|
for version in PhpEnvironments.shared.availablePhpVersions.reversed() {
|
||||||
let item = PhpMenuItem(
|
let item = PhpMenuItem(
|
||||||
title: "domain_list.always_use_php".localized(version),
|
title: "domain_list.always_use_php".localized(version),
|
||||||
action: #selector(self.isolateSite),
|
action: #selector(self.isolateSite),
|
||||||
|
@ -27,7 +27,7 @@ import Foundation
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
PhpEnv.shared.isBusy = true
|
PhpEnvironments.shared.isBusy = true
|
||||||
MainMenu.shared.setBusyImage()
|
MainMenu.shared.setBusyImage()
|
||||||
MainMenu.shared.rebuild()
|
MainMenu.shared.rebuild()
|
||||||
|
|
||||||
@ -105,7 +105,7 @@ import Foundation
|
|||||||
// MARK: Main Menu Update
|
// MARK: Main Menu Update
|
||||||
|
|
||||||
private func removeBusyStatus() {
|
private func removeBusyStatus() {
|
||||||
PhpEnv.shared.isBusy = false
|
PhpEnvironments.shared.isBusy = false
|
||||||
Task { @MainActor in
|
Task { @MainActor in
|
||||||
MainMenu.shared.updatePhpVersionInStatusBar()
|
MainMenu.shared.updatePhpVersionInStatusBar()
|
||||||
}
|
}
|
||||||
|
@ -54,10 +54,10 @@ class BrewPermissionFixer {
|
|||||||
whether the Homebrew binary directory for the given PHP version is owned by root.
|
whether the Homebrew binary directory for the given PHP version is owned by root.
|
||||||
*/
|
*/
|
||||||
private func determineBrokenFormulae() async {
|
private func determineBrokenFormulae() async {
|
||||||
let formulae = PhpEnv.shared.cachedPhpInstallations.keys
|
let formulae = PhpEnvironments.shared.cachedPhpInstallations.keys
|
||||||
|
|
||||||
for formula in formulae {
|
for formula in formulae {
|
||||||
let realFormula = formula == PhpEnv.brewPhpAlias
|
let realFormula = formula == PhpEnvironments.brewPhpAlias
|
||||||
? "php"
|
? "php"
|
||||||
: "php@\(formula)"
|
: "php@\(formula)"
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ class BrewDiagnostics {
|
|||||||
public static func checkForValetMisconfiguration() async {
|
public static func checkForValetMisconfiguration() async {
|
||||||
Log.info("Checking for PHP-FPM issues with Valet...")
|
Log.info("Checking for PHP-FPM issues with Valet...")
|
||||||
|
|
||||||
guard let install = PhpEnv.phpInstall else {
|
guard let install = PhpEnvironments.phpInstall else {
|
||||||
Log.info("Will skip check for issues if no PHP version is linked.")
|
Log.info("Will skip check for issues if no PHP version is linked.")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -103,13 +103,13 @@ class BrewDiagnostics {
|
|||||||
from: tapAlias.data(using: .utf8)!
|
from: tapAlias.data(using: .utf8)!
|
||||||
).first!
|
).first!
|
||||||
|
|
||||||
if tapPhp.version != PhpEnv.brewPhpAlias {
|
if tapPhp.version != PhpEnvironments.brewPhpAlias {
|
||||||
Log.warn("The `php` formula alias seems to be the different between the tap and core. "
|
Log.warn("The `php` formula alias seems to be the different between the tap and core. "
|
||||||
+ "This could be a problem!")
|
+ "This could be a problem!")
|
||||||
Log.info("Determining whether both of these versions are installed...")
|
Log.info("Determining whether both of these versions are installed...")
|
||||||
|
|
||||||
let bothInstalled = PhpEnv.shared.availablePhpVersions.contains(tapPhp.version)
|
let bothInstalled = PhpEnvironments.shared.availablePhpVersions.contains(tapPhp.version)
|
||||||
&& PhpEnv.shared.availablePhpVersions.contains(PhpEnv.brewPhpAlias)
|
&& PhpEnvironments.shared.availablePhpVersions.contains(PhpEnvironments.brewPhpAlias)
|
||||||
|
|
||||||
if bothInstalled {
|
if bothInstalled {
|
||||||
Log.warn("Both conflicting aliases seem to be installed, warning the user!")
|
Log.warn("Both conflicting aliases seem to be installed, warning the user!")
|
||||||
|
@ -35,7 +35,7 @@ struct BrewFormula {
|
|||||||
var homebrewFolder: String {
|
var homebrewFolder: String {
|
||||||
let resolved = name
|
let resolved = name
|
||||||
.replacingOccurrences(of: "shivammathur/php/", with: "")
|
.replacingOccurrences(of: "shivammathur/php/", with: "")
|
||||||
.replacingOccurrences(of: "php@" + PhpEnv.brewPhpAlias, with: "php")
|
.replacingOccurrences(of: "php@" + PhpEnvironments.brewPhpAlias, with: "php")
|
||||||
|
|
||||||
return "\(Paths.optPath)/\(resolved)/bin"
|
return "\(Paths.optPath)/\(resolved)/bin"
|
||||||
}
|
}
|
||||||
@ -64,6 +64,6 @@ struct BrewFormula {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return PhpEnv.shared.cachedPhpInstallations[shortVersion]?.isHealthy ?? nil
|
return PhpEnvironments.shared.cachedPhpInstallations[shortVersion]?.isHealthy ?? nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ class BrewFormulaeHandler: HandlesBrewFormulae {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return Brew.phpVersionFormulae.map { (version, formula) in
|
return Brew.phpVersionFormulae.map { (version, formula) in
|
||||||
let fullVersion = PhpEnv.shared.cachedPhpInstallations[version]?.versionNumber.text
|
let fullVersion = PhpEnvironments.shared.cachedPhpInstallations[version]?.versionNumber.text
|
||||||
var upgradeVersion: String?
|
var upgradeVersion: String?
|
||||||
|
|
||||||
if let version = fullVersion {
|
if let version = fullVersion {
|
||||||
|
@ -38,7 +38,7 @@ class InstallAndUpgradeCommand: BrewCommand {
|
|||||||
try await self.installPackages(onProgress)
|
try await self.installPackages(onProgress)
|
||||||
|
|
||||||
// Re-check the installed versions
|
// Re-check the installed versions
|
||||||
await PhpEnv.detectPhpVersions()
|
await PhpEnvironments.detectPhpVersions()
|
||||||
|
|
||||||
// After performing operations, attempt to run repairs if needed
|
// After performing operations, attempt to run repairs if needed
|
||||||
try await self.repairBrokenPackages(onProgress)
|
try await self.repairBrokenPackages(onProgress)
|
||||||
@ -80,13 +80,13 @@ class InstallAndUpgradeCommand: BrewCommand {
|
|||||||
private func repairBrokenPackages(_ onProgress: @escaping (BrewCommandProgress) -> Void) async throws {
|
private func repairBrokenPackages(_ onProgress: @escaping (BrewCommandProgress) -> Void) async throws {
|
||||||
// Determine which PHP installations are considered unhealthy
|
// Determine which PHP installations are considered unhealthy
|
||||||
// Build a list of formulae to reinstall
|
// Build a list of formulae to reinstall
|
||||||
let requiringRepair = PhpEnv.shared
|
let requiringRepair = PhpEnvironments.shared
|
||||||
.cachedPhpInstallations.values
|
.cachedPhpInstallations.values
|
||||||
.filter({ !$0.isHealthy })
|
.filter({ !$0.isHealthy })
|
||||||
.map { installation in
|
.map { installation in
|
||||||
let formula = "php@\(installation.versionNumber.short)"
|
let formula = "php@\(installation.versionNumber.short)"
|
||||||
|
|
||||||
if installation.versionNumber.short == PhpEnv.brewPhpAlias {
|
if installation.versionNumber.short == PhpEnvironments.brewPhpAlias {
|
||||||
return "php"
|
return "php"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -140,7 +140,7 @@ class InstallAndUpgradeCommand: BrewCommand {
|
|||||||
onProgress(.create(value: 0.95, title: self.title, description: "Reloading PHP versions..."))
|
onProgress(.create(value: 0.95, title: self.title, description: "Reloading PHP versions..."))
|
||||||
|
|
||||||
// Check which version of PHP are now installed
|
// Check which version of PHP are now installed
|
||||||
await PhpEnv.detectPhpVersions()
|
await PhpEnvironments.detectPhpVersions()
|
||||||
|
|
||||||
// Keep track of the currently installed version
|
// Keep track of the currently installed version
|
||||||
await MainMenu.shared.refreshActiveInstallation()
|
await MainMenu.shared.refreshActiveInstallation()
|
||||||
|
@ -55,7 +55,7 @@ class RemovePhpVersionCommand: BrewCommand {
|
|||||||
|
|
||||||
if process.terminationStatus <= 0 {
|
if process.terminationStatus <= 0 {
|
||||||
onProgress(.create(value: 0.95, title: progressTitle, description: "Reloading PHP versions..."))
|
onProgress(.create(value: 0.95, title: progressTitle, description: "Reloading PHP versions..."))
|
||||||
await PhpEnv.detectPhpVersions()
|
await PhpEnvironments.detectPhpVersions()
|
||||||
await MainMenu.shared.refreshActiveInstallation()
|
await MainMenu.shared.refreshActiveInstallation()
|
||||||
onProgress(.create(value: 1, title: progressTitle, description: "The operation has succeeded."))
|
onProgress(.create(value: 1, title: progressTitle, description: "The operation has succeeded."))
|
||||||
} else {
|
} else {
|
||||||
|
@ -75,7 +75,7 @@ class FakeValetInteractor: ValetInteractor {
|
|||||||
override func isolate(site: ValetSite, version: String) async throws {
|
override func isolate(site: ValetSite, version: String) async throws {
|
||||||
await delay(seconds: delayTime)
|
await delay(seconds: delayTime)
|
||||||
|
|
||||||
site.isolatedPhpVersion = PhpEnv.shared.cachedPhpInstallations[version]
|
site.isolatedPhpVersion = PhpEnvironments.shared.cachedPhpInstallations[version]
|
||||||
site.evaluateCompatibility()
|
site.evaluateCompatibility()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ class FakeValetSite: ValetSite {
|
|||||||
self.isolatedPhpVersion = PhpInstallation(isolated)
|
self.isolatedPhpVersion = PhpInstallation(isolated)
|
||||||
}
|
}
|
||||||
|
|
||||||
if PhpEnv.shared.currentInstall != nil {
|
if PhpEnvironments.shared.currentInstall != nil {
|
||||||
self.evaluateCompatibility()
|
self.evaluateCompatibility()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -57,7 +57,7 @@ class ValetSite: ValetListable {
|
|||||||
/// Which version of PHP is actually used to serve this site.
|
/// Which version of PHP is actually used to serve this site.
|
||||||
var servingPhpVersion: String {
|
var servingPhpVersion: String {
|
||||||
return self.isolatedPhpVersion?.versionNumber.short
|
return self.isolatedPhpVersion?.versionNumber.short
|
||||||
?? PhpEnv.phpInstall?.version.short
|
?? PhpEnvironments.phpInstall?.version.short
|
||||||
?? "???"
|
?? "???"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,12 +98,12 @@ class ValetSite: ValetListable {
|
|||||||
*/
|
*/
|
||||||
public func determineIsolated() {
|
public func determineIsolated() {
|
||||||
if let version = ValetSite.isolatedVersion("~/.config/valet/Nginx/\(self.name).\(self.tld)") {
|
if let version = ValetSite.isolatedVersion("~/.config/valet/Nginx/\(self.name).\(self.tld)") {
|
||||||
if !PhpEnv.shared.cachedPhpInstallations.keys.contains(version) {
|
if !PhpEnvironments.shared.cachedPhpInstallations.keys.contains(version) {
|
||||||
Log.err("The PHP version \(version) is isolated for the site \(self.name) "
|
Log.err("The PHP version \(version) is isolated for the site \(self.name) "
|
||||||
+ "but that PHP version is unavailable.")
|
+ "but that PHP version is unavailable.")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
self.isolatedPhpVersion = PhpEnv.shared.cachedPhpInstallations[version]
|
self.isolatedPhpVersion = PhpEnvironments.shared.cachedPhpInstallations[version]
|
||||||
} else {
|
} else {
|
||||||
self.isolatedPhpVersion = nil
|
self.isolatedPhpVersion = nil
|
||||||
}
|
}
|
||||||
@ -238,7 +238,7 @@ class ValetSite: ValetListable {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
guard let linked = PhpEnv.phpInstall else {
|
guard let linked = PhpEnvironments.phpInstall else {
|
||||||
self.isCompatibleWithPreferredPhpVersion = false
|
self.isCompatibleWithPreferredPhpVersion = false
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -157,7 +157,7 @@ class Valet {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if PhpEnv.phpInstall == nil {
|
if PhpEnvironments.phpInstall == nil {
|
||||||
Log.info("Cannot validate Valet version if no PHP version is linked.")
|
Log.info("Cannot validate Valet version if no PHP version is linked.")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -192,7 +192,7 @@ class Valet {
|
|||||||
that means that Valet won't work properly.
|
that means that Valet won't work properly.
|
||||||
*/
|
*/
|
||||||
func phpFpmConfigurationValid() async -> Bool {
|
func phpFpmConfigurationValid() async -> Bool {
|
||||||
guard let version = PhpEnv.shared.currentInstall?.version else {
|
guard let version = PhpEnvironments.shared.currentInstall?.version else {
|
||||||
Log.info("Cannot check PHP-FPM status: no version of PHP is active")
|
Log.info("Cannot check PHP-FPM status: no version of PHP is active")
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
@ -105,7 +105,7 @@ extension MainMenu {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@objc func disableAllXdebugModes() {
|
@objc func disableAllXdebugModes() {
|
||||||
guard let file = PhpEnv.shared.getConfigFile(forKey: "xdebug.mode") else {
|
guard let file = PhpEnvironments.shared.getConfigFile(forKey: "xdebug.mode") else {
|
||||||
Log.info("xdebug.mode could not be found in any .ini file, aborting.")
|
Log.info("xdebug.mode could not be found in any .ini file, aborting.")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -124,7 +124,7 @@ extension MainMenu {
|
|||||||
@objc func toggleXdebugMode(sender: XdebugMenuItem) {
|
@objc func toggleXdebugMode(sender: XdebugMenuItem) {
|
||||||
Log.info("Switching Xdebug to mode: \(sender.mode)")
|
Log.info("Switching Xdebug to mode: \(sender.mode)")
|
||||||
|
|
||||||
guard let file = PhpEnv.shared.getConfigFile(forKey: "xdebug.mode") else {
|
guard let file = PhpEnvironments.shared.getConfigFile(forKey: "xdebug.mode") else {
|
||||||
return Log.info("xdebug.mode could not be found in any .ini file, aborting.")
|
return Log.info("xdebug.mode could not be found in any .ini file, aborting.")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -226,7 +226,7 @@ extension MainMenu {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@objc func openActiveConfigFolder() {
|
@objc func openActiveConfigFolder() {
|
||||||
guard let install = PhpEnv.phpInstall else {
|
guard let install = PhpEnvironments.phpInstall else {
|
||||||
// TODO: Can't open the config if no PHP version is active
|
// TODO: Can't open the config if no PHP version is active
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -259,7 +259,7 @@ extension MainMenu {
|
|||||||
if silently {
|
if silently {
|
||||||
MainMenu.shared.shouldSwitchSilently = true
|
MainMenu.shared.shouldSwitchSilently = true
|
||||||
}
|
}
|
||||||
if PhpEnv.shared.availablePhpVersions.contains(version) {
|
if PhpEnvironments.shared.availablePhpVersions.contains(version) {
|
||||||
Task { MainMenu.shared.switchToPhpVersion(version) }
|
Task { MainMenu.shared.switchToPhpVersion(version) }
|
||||||
} else {
|
} else {
|
||||||
Task {
|
Task {
|
||||||
@ -275,18 +275,18 @@ extension MainMenu {
|
|||||||
|
|
||||||
@objc func switchToPhpVersion(_ version: String) {
|
@objc func switchToPhpVersion(_ version: String) {
|
||||||
setBusyImage()
|
setBusyImage()
|
||||||
PhpEnv.shared.isBusy = true
|
PhpEnvironments.shared.isBusy = true
|
||||||
PhpEnv.shared.delegate = self
|
PhpEnvironments.shared.delegate = self
|
||||||
PhpEnv.shared.delegate?.switcherDidStartSwitching(to: version)
|
PhpEnvironments.shared.delegate?.switcherDidStartSwitching(to: version)
|
||||||
|
|
||||||
Task(priority: .userInitiated) { [unowned self] in
|
Task(priority: .userInitiated) { [unowned self] in
|
||||||
updatePhpVersionInStatusBar()
|
updatePhpVersionInStatusBar()
|
||||||
rebuild()
|
rebuild()
|
||||||
await PhpEnv.switcher.performSwitch(to: version)
|
await PhpEnvironments.switcher.performSwitch(to: version)
|
||||||
|
|
||||||
PhpEnv.shared.currentInstall = ActivePhpInstallation()
|
PhpEnvironments.shared.currentInstall = ActivePhpInstallation()
|
||||||
App.shared.handlePhpConfigWatcher()
|
App.shared.handlePhpConfigWatcher()
|
||||||
PhpEnv.shared.delegate?.switcherDidCompleteSwitch(to: version)
|
PhpEnvironments.shared.delegate?.switcherDidCompleteSwitch(to: version)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -302,18 +302,18 @@ extension MainMenu {
|
|||||||
func switchToPhp(_ version: String) async {
|
func switchToPhp(_ version: String) async {
|
||||||
Task { @MainActor [self] in
|
Task { @MainActor [self] in
|
||||||
setBusyImage()
|
setBusyImage()
|
||||||
PhpEnv.shared.isBusy = true
|
PhpEnvironments.shared.isBusy = true
|
||||||
PhpEnv.shared.delegate = self
|
PhpEnvironments.shared.delegate = self
|
||||||
PhpEnv.shared.delegate?.switcherDidStartSwitching(to: version)
|
PhpEnvironments.shared.delegate?.switcherDidStartSwitching(to: version)
|
||||||
}
|
}
|
||||||
|
|
||||||
updatePhpVersionInStatusBar()
|
updatePhpVersionInStatusBar()
|
||||||
rebuild()
|
rebuild()
|
||||||
await PhpEnv.switcher.performSwitch(to: version)
|
await PhpEnvironments.switcher.performSwitch(to: version)
|
||||||
|
|
||||||
PhpEnv.shared.currentInstall = ActivePhpInstallation()
|
PhpEnvironments.shared.currentInstall = ActivePhpInstallation()
|
||||||
App.shared.handlePhpConfigWatcher()
|
App.shared.handlePhpConfigWatcher()
|
||||||
PhpEnv.shared.delegate?.switcherDidCompleteSwitch(to: version)
|
PhpEnvironments.shared.delegate?.switcherDidCompleteSwitch(to: version)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,7 @@ extension MainMenu {
|
|||||||
]
|
]
|
||||||
) {
|
) {
|
||||||
if behaviours.contains(.reloadsPhpInstallation) {
|
if behaviours.contains(.reloadsPhpInstallation) {
|
||||||
PhpEnv.shared.isBusy = true
|
PhpEnvironments.shared.isBusy = true
|
||||||
}
|
}
|
||||||
|
|
||||||
if behaviours.contains(.setsBusyUI) {
|
if behaviours.contains(.setsBusyUI) {
|
||||||
@ -59,12 +59,12 @@ extension MainMenu {
|
|||||||
do { try execute() } catch let e { error = e }
|
do { try execute() } catch let e { error = e }
|
||||||
|
|
||||||
if behaviours.contains(.setsBusyUI) {
|
if behaviours.contains(.setsBusyUI) {
|
||||||
PhpEnv.shared.isBusy = false
|
PhpEnvironments.shared.isBusy = false
|
||||||
}
|
}
|
||||||
|
|
||||||
Task { @MainActor [self, error] in
|
Task { @MainActor [self, error] in
|
||||||
if behaviours.contains(.reloadsPhpInstallation) {
|
if behaviours.contains(.reloadsPhpInstallation) {
|
||||||
PhpEnv.shared.currentInstall = ActivePhpInstallation()
|
PhpEnvironments.shared.currentInstall = ActivePhpInstallation()
|
||||||
}
|
}
|
||||||
|
|
||||||
if behaviours.contains(.updatesMenuBarContents) {
|
if behaviours.contains(.updatesMenuBarContents) {
|
||||||
|
@ -12,9 +12,9 @@ import AppKit
|
|||||||
extension MainMenu {
|
extension MainMenu {
|
||||||
|
|
||||||
@MainActor @objc func fixMyValet() {
|
@MainActor @objc func fixMyValet() {
|
||||||
let previousVersion = PhpEnv.phpInstall?.version.short
|
let previousVersion = PhpEnvironments.phpInstall?.version.short
|
||||||
|
|
||||||
if !PhpEnv.shared.availablePhpVersions.contains(PhpEnv.brewPhpAlias) {
|
if !PhpEnvironments.shared.availablePhpVersions.contains(PhpEnvironments.brewPhpAlias) {
|
||||||
presentAlertForMissingFormula()
|
presentAlertForMissingFormula()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -22,7 +22,7 @@ extension MainMenu {
|
|||||||
if !BetterAlert()
|
if !BetterAlert()
|
||||||
.withInformation(
|
.withInformation(
|
||||||
title: "alert.fix_my_valet.title".localized,
|
title: "alert.fix_my_valet.title".localized,
|
||||||
subtitle: "alert.fix_my_valet.info".localized(PhpEnv.brewPhpAlias)
|
subtitle: "alert.fix_my_valet.info".localized(PhpEnvironments.brewPhpAlias)
|
||||||
)
|
)
|
||||||
.withPrimary(text: "alert.fix_my_valet.ok".localized)
|
.withPrimary(text: "alert.fix_my_valet.ok".localized)
|
||||||
.withSecondary(text: "alert.fix_my_valet.cancel".localized)
|
.withSecondary(text: "alert.fix_my_valet.cancel".localized)
|
||||||
@ -34,7 +34,7 @@ extension MainMenu {
|
|||||||
Task { @MainActor in
|
Task { @MainActor in
|
||||||
await Actions.fixMyValet()
|
await Actions.fixMyValet()
|
||||||
|
|
||||||
if previousVersion == PhpEnv.brewPhpAlias || previousVersion == nil {
|
if previousVersion == PhpEnvironments.brewPhpAlias || previousVersion == nil {
|
||||||
self.presentAlertForSameVersion()
|
self.presentAlertForSameVersion()
|
||||||
} else {
|
} else {
|
||||||
self.presentAlertForDifferentVersion(version: previousVersion!)
|
self.presentAlertForDifferentVersion(version: previousVersion!)
|
||||||
@ -74,7 +74,7 @@ extension MainMenu {
|
|||||||
alert.close(with: .alertSecondButtonReturn)
|
alert.close(with: .alertSecondButtonReturn)
|
||||||
MainMenu.shared.switchToPhpVersion(version)
|
MainMenu.shared.switchToPhpVersion(version)
|
||||||
})
|
})
|
||||||
.withSecondary(text: "alert.fix_my_valet_done.stay".localized(PhpEnv.brewPhpAlias))
|
.withSecondary(text: "alert.fix_my_valet_done.stay".localized(PhpEnvironments.brewPhpAlias))
|
||||||
.withTertiary(text: "", action: { _ in
|
.withTertiary(text: "", action: { _ in
|
||||||
NSWorkspace.shared.open(Constants.Urls.FrequentlyAskedQuestions)
|
NSWorkspace.shared.open(Constants.Urls.FrequentlyAskedQuestions)
|
||||||
})
|
})
|
||||||
|
@ -32,7 +32,7 @@ extension MainMenu {
|
|||||||
*/
|
*/
|
||||||
private func onEnvironmentPass() async {
|
private func onEnvironmentPass() async {
|
||||||
// Determine what the `php` formula is aliased to
|
// Determine what the `php` formula is aliased to
|
||||||
await PhpEnv.shared.determinePhpAlias()
|
await PhpEnvironments.shared.determinePhpAlias()
|
||||||
|
|
||||||
// Initialize preferences
|
// Initialize preferences
|
||||||
_ = Preferences.shared
|
_ = Preferences.shared
|
||||||
@ -60,7 +60,7 @@ extension MainMenu {
|
|||||||
await Brew.shared.determineVersion()
|
await Brew.shared.determineVersion()
|
||||||
|
|
||||||
// Actually detect the PHP versions
|
// Actually detect the PHP versions
|
||||||
await PhpEnv.detectPhpVersions()
|
await PhpEnvironments.detectPhpVersions()
|
||||||
|
|
||||||
// Check for an alias conflict
|
// Check for an alias conflict
|
||||||
await BrewDiagnostics.checkForCaskConflict()
|
await BrewDiagnostics.checkForCaskConflict()
|
||||||
@ -69,7 +69,7 @@ extension MainMenu {
|
|||||||
updatePhpVersionInStatusBar()
|
updatePhpVersionInStatusBar()
|
||||||
|
|
||||||
// Attempt to find out if PHP-FPM is broken
|
// Attempt to find out if PHP-FPM is broken
|
||||||
PhpEnv.prepare()
|
PhpEnvironments.prepare()
|
||||||
|
|
||||||
// Set up the filesystem watcher for the Homebrew binaries
|
// Set up the filesystem watcher for the Homebrew binaries
|
||||||
App.shared.prepareHomebrewWatchers()
|
App.shared.prepareHomebrewWatchers()
|
||||||
|
@ -16,7 +16,7 @@ extension MainMenu {
|
|||||||
|
|
||||||
nonisolated func switcherDidCompleteSwitch(to version: String) {
|
nonisolated func switcherDidCompleteSwitch(to version: String) {
|
||||||
// Mark as no longer busy
|
// Mark as no longer busy
|
||||||
PhpEnv.shared.isBusy = false
|
PhpEnvironments.shared.isBusy = false
|
||||||
|
|
||||||
Task { // Things to do after reloading domain list data
|
Task { // Things to do after reloading domain list data
|
||||||
if Valet.installed {
|
if Valet.installed {
|
||||||
@ -28,7 +28,7 @@ extension MainMenu {
|
|||||||
updatePhpVersionInStatusBar()
|
updatePhpVersionInStatusBar()
|
||||||
rebuild()
|
rebuild()
|
||||||
|
|
||||||
if !PhpEnv.shared.validate(version) {
|
if !PhpEnvironments.shared.validate(version) {
|
||||||
self.suggestFixMyValet(failed: version)
|
self.suggestFixMyValet(failed: version)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -125,7 +125,7 @@ extension MainMenu {
|
|||||||
preference: .notifyAboutVersionChange
|
preference: .notifyAboutVersionChange
|
||||||
)
|
)
|
||||||
|
|
||||||
guard PhpEnv.phpInstall != nil else {
|
guard PhpEnvironments.phpInstall != nil else {
|
||||||
Log.err("Cannot notify about version change if PHP is unlinked")
|
Log.err("Cannot notify about version change if PHP is unlinked")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -78,8 +78,8 @@ class MainMenu: NSObject, NSWindowDelegate, NSMenuDelegate, PhpSwitcherDelegate
|
|||||||
|
|
||||||
/** Reloads which PHP versions is currently active. */
|
/** Reloads which PHP versions is currently active. */
|
||||||
@objc func refreshActiveInstallation() {
|
@objc func refreshActiveInstallation() {
|
||||||
if !PhpEnv.shared.isBusy {
|
if !PhpEnvironments.shared.isBusy {
|
||||||
PhpEnv.shared.currentInstall = ActivePhpInstallation.load()
|
PhpEnvironments.shared.currentInstall = ActivePhpInstallation.load()
|
||||||
updatePhpVersionInStatusBar()
|
updatePhpVersionInStatusBar()
|
||||||
} else {
|
} else {
|
||||||
Log.perf("Skipping version refresh due to busy status!")
|
Log.perf("Skipping version refresh due to busy status!")
|
||||||
@ -122,7 +122,7 @@ class MainMenu: NSObject, NSWindowDelegate, NSMenuDelegate, PhpSwitcherDelegate
|
|||||||
BetterAlert().withInformation(
|
BetterAlert().withInformation(
|
||||||
title: "startup.unsupported_versions_explanation.title".localized,
|
title: "startup.unsupported_versions_explanation.title".localized,
|
||||||
subtitle: "startup.unsupported_versions_explanation.subtitle".localized(
|
subtitle: "startup.unsupported_versions_explanation.subtitle".localized(
|
||||||
PhpEnv.shared.incompatiblePhpVersions
|
PhpEnvironments.shared.incompatiblePhpVersions
|
||||||
.map({ version in
|
.map({ version in
|
||||||
return "• PHP \(version)"
|
return "• PHP \(version)"
|
||||||
})
|
})
|
||||||
@ -151,7 +151,7 @@ class MainMenu: NSObject, NSWindowDelegate, NSMenuDelegate, PhpSwitcherDelegate
|
|||||||
/** Refreshes the icon with the PHP version. */
|
/** Refreshes the icon with the PHP version. */
|
||||||
@objc func refreshIcon() {
|
@objc func refreshIcon() {
|
||||||
Task { @MainActor [self] in
|
Task { @MainActor [self] in
|
||||||
if PhpEnv.shared.isBusy {
|
if PhpEnvironments.shared.isBusy {
|
||||||
setStatusBar(image: NSImage(named: NSImage.Name("StatusBarIcon"))!)
|
setStatusBar(image: NSImage(named: NSImage.Name("StatusBarIcon"))!)
|
||||||
} else {
|
} else {
|
||||||
if Preferences.preferences[.shouldDisplayDynamicIcon] as! Bool == false {
|
if Preferences.preferences[.shouldDisplayDynamicIcon] as! Bool == false {
|
||||||
@ -161,7 +161,7 @@ class MainMenu: NSObject, NSWindowDelegate, NSMenuDelegate, PhpSwitcherDelegate
|
|||||||
// The dynamic icon has been requested
|
// The dynamic icon has been requested
|
||||||
let long = Preferences.preferences[.fullPhpVersionDynamicIcon] as! Bool
|
let long = Preferences.preferences[.fullPhpVersionDynamicIcon] as! Bool
|
||||||
|
|
||||||
guard let install = PhpEnv.phpInstall else {
|
guard let install = PhpEnvironments.phpInstall else {
|
||||||
setStatusBarImage(version: "???")
|
setStatusBarImage(version: "???")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ import Cocoa
|
|||||||
extension StatusMenu {
|
extension StatusMenu {
|
||||||
|
|
||||||
func addPhpVersionMenuItems() {
|
func addPhpVersionMenuItems() {
|
||||||
if PhpEnv.phpInstall == nil {
|
if PhpEnvironments.phpInstall == nil {
|
||||||
addItem(HeaderView.asMenuItem(text: "⚠️ " + "mi_no_php_linked".localized, minimumWidth: 280))
|
addItem(HeaderView.asMenuItem(text: "⚠️ " + "mi_no_php_linked".localized, minimumWidth: 280))
|
||||||
addItems([
|
addItems([
|
||||||
NSMenuItem.separator(),
|
NSMenuItem.separator(),
|
||||||
@ -23,28 +23,29 @@ extension StatusMenu {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if PhpEnv.phpInstall!.hasErrorState {
|
if PhpEnvironments.phpInstall!.hasErrorState {
|
||||||
let brokenMenuItems = ["mi_php_broken_1", "mi_php_broken_2", "mi_php_broken_3", "mi_php_broken_4"]
|
let brokenMenuItems = ["mi_php_broken_1", "mi_php_broken_2", "mi_php_broken_3", "mi_php_broken_4"]
|
||||||
return addItems(brokenMenuItems.map { NSMenuItem(title: $0.localized) })
|
return addItems(brokenMenuItems.map { NSMenuItem(title: $0.localized) })
|
||||||
}
|
}
|
||||||
|
|
||||||
addItem(HeaderView.asMenuItem(
|
addItem(HeaderView.asMenuItem(
|
||||||
text: "\("mi_php_version".localized) \(PhpEnv.phpInstall!.version.long)",
|
text: "\("mi_php_version".localized) \(PhpEnvironments.phpInstall!.version.long)",
|
||||||
minimumWidth: 280 // this ensures the menu is at least wide enough not to cause clipping
|
minimumWidth: 280 // this ensures the menu is at least wide enough not to cause clipping
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
func addPhpActionMenuItems() {
|
func addPhpActionMenuItems() {
|
||||||
if PhpEnv.shared.isBusy {
|
if PhpEnvironments.shared.isBusy {
|
||||||
addItem(NSMenuItem(title: "mi_busy".localized))
|
addItem(NSMenuItem(title: "mi_busy".localized))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if PhpEnv.shared.availablePhpVersions.isEmpty && PhpEnv.shared.incompatiblePhpVersions.isEmpty {
|
if PhpEnvironments.shared.availablePhpVersions.isEmpty
|
||||||
|
&& PhpEnvironments.shared.incompatiblePhpVersions.isEmpty {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if PhpEnv.shared.currentInstall == nil {
|
if PhpEnvironments.shared.currentInstall == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,7 +55,7 @@ extension StatusMenu {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func addServicesManagerMenuItem() {
|
func addServicesManagerMenuItem() {
|
||||||
if PhpEnv.shared.isBusy {
|
if PhpEnvironments.shared.isBusy {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,20 +67,20 @@ extension StatusMenu {
|
|||||||
|
|
||||||
func addSwitchToPhpMenuItems() {
|
func addSwitchToPhpMenuItems() {
|
||||||
var shortcutKey = 1
|
var shortcutKey = 1
|
||||||
for index in (0..<PhpEnv.shared.availablePhpVersions.count) {
|
for index in (0..<PhpEnvironments.shared.availablePhpVersions.count) {
|
||||||
// Get the short and long version
|
// Get the short and long version
|
||||||
let shortVersion = PhpEnv.shared.availablePhpVersions[index]
|
let shortVersion = PhpEnvironments.shared.availablePhpVersions[index]
|
||||||
let longVersion = PhpEnv.shared.cachedPhpInstallations[shortVersion]!.versionNumber
|
let longVersion = PhpEnvironments.shared.cachedPhpInstallations[shortVersion]!.versionNumber
|
||||||
|
|
||||||
let long = Preferences.preferences[.fullPhpVersionDynamicIcon] as! Bool
|
let long = Preferences.preferences[.fullPhpVersionDynamicIcon] as! Bool
|
||||||
let versionString = long ? longVersion.text : shortVersion
|
let versionString = long ? longVersion.text : shortVersion
|
||||||
|
|
||||||
let action = #selector(MainMenu.switchToPhpVersion(sender:))
|
let action = #selector(MainMenu.switchToPhpVersion(sender:))
|
||||||
let brew = (shortVersion == PhpEnv.brewPhpAlias) ? "php" : "php@\(shortVersion)"
|
let brew = (shortVersion == PhpEnvironments.brewPhpAlias) ? "php" : "php@\(shortVersion)"
|
||||||
|
|
||||||
let menuItem = PhpMenuItem(
|
let menuItem = PhpMenuItem(
|
||||||
title: "\("mi_php_switch".localized) \(versionString) (\(brew))",
|
title: "\("mi_php_switch".localized) \(versionString) (\(brew))",
|
||||||
action: (shortVersion == PhpEnv.phpInstall?.version.short)
|
action: (shortVersion == PhpEnvironments.phpInstall?.version.short)
|
||||||
? nil
|
? nil
|
||||||
: action, keyEquivalent: "\(shortcutKey)"
|
: action, keyEquivalent: "\(shortcutKey)"
|
||||||
)
|
)
|
||||||
@ -90,11 +91,11 @@ extension StatusMenu {
|
|||||||
addItem(menuItem)
|
addItem(menuItem)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !PhpEnv.shared.incompatiblePhpVersions.isEmpty {
|
if !PhpEnvironments.shared.incompatiblePhpVersions.isEmpty {
|
||||||
addItem(NSMenuItem.separator())
|
addItem(NSMenuItem.separator())
|
||||||
addItem(NSMenuItem(
|
addItem(NSMenuItem(
|
||||||
title: "⚠️ " + "mi_php_unsupported".localized(
|
title: "⚠️ " + "mi_php_unsupported".localized(
|
||||||
"\(PhpEnv.shared.incompatiblePhpVersions.count)"
|
"\(PhpEnvironments.shared.incompatiblePhpVersions.count)"
|
||||||
),
|
),
|
||||||
action: #selector(MainMenu.showIncompatiblePhpVersionsAlert)
|
action: #selector(MainMenu.showIncompatiblePhpVersionsAlert)
|
||||||
))
|
))
|
||||||
@ -175,7 +176,7 @@ extension StatusMenu {
|
|||||||
),
|
),
|
||||||
NSMenuItem(
|
NSMenuItem(
|
||||||
title: "mi_update_global_composer".localized,
|
title: "mi_update_global_composer".localized,
|
||||||
action: PhpEnv.shared.isBusy
|
action: PhpEnvironments.shared.isBusy
|
||||||
? nil
|
? nil
|
||||||
: #selector(MainMenu.updateGlobalComposerDependencies),
|
: #selector(MainMenu.updateGlobalComposerDependencies),
|
||||||
keyEquivalent: "g",
|
keyEquivalent: "g",
|
||||||
@ -187,7 +188,7 @@ extension StatusMenu {
|
|||||||
// MARK: - Stats
|
// MARK: - Stats
|
||||||
|
|
||||||
func addStatsMenuItem() {
|
func addStatsMenuItem() {
|
||||||
guard let install = PhpEnv.phpInstall else {
|
guard let install = PhpEnvironments.phpInstall else {
|
||||||
Log.info("Not showing stats menu item if no PHP version is linked.")
|
Log.info("Not showing stats menu item if no PHP version is linked.")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -204,7 +205,7 @@ extension StatusMenu {
|
|||||||
// MARK: - Extensions
|
// MARK: - Extensions
|
||||||
|
|
||||||
func addExtensionsMenuItems() {
|
func addExtensionsMenuItems() {
|
||||||
guard let install = PhpEnv.phpInstall else {
|
guard let install = PhpEnvironments.phpInstall else {
|
||||||
Log.info("Not showing extensions menu items if no PHP version is linked.")
|
Log.info("Not showing extensions menu items if no PHP version is linked.")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -311,7 +312,7 @@ extension StatusMenu {
|
|||||||
if Valet.installed {
|
if Valet.installed {
|
||||||
items.append(contentsOf: [
|
items.append(contentsOf: [
|
||||||
NSMenuItem.separator(),
|
NSMenuItem.separator(),
|
||||||
NSMenuItem(title: "mi_fix_my_valet".localized(PhpEnv.brewPhpAlias),
|
NSMenuItem(title: "mi_fix_my_valet".localized(PhpEnvironments.brewPhpAlias),
|
||||||
action: #selector(MainMenu.fixMyValet),
|
action: #selector(MainMenu.fixMyValet),
|
||||||
toolTip: "mi_fix_my_valet_tooltip".localized),
|
toolTip: "mi_fix_my_valet_tooltip".localized),
|
||||||
NSMenuItem(title: "mi_fix_brew_permissions".localized(),
|
NSMenuItem(title: "mi_fix_brew_permissions".localized(),
|
||||||
|
@ -13,12 +13,12 @@ class StatusMenu: NSMenu {
|
|||||||
addPhpVersionMenuItems()
|
addPhpVersionMenuItems()
|
||||||
addItem(NSMenuItem.separator())
|
addItem(NSMenuItem.separator())
|
||||||
|
|
||||||
if PhpEnv.phpInstall != nil && Preferences.isEnabled(.displayGlobalVersionSwitcher) {
|
if PhpEnvironments.phpInstall != nil && Preferences.isEnabled(.displayGlobalVersionSwitcher) {
|
||||||
addPhpActionMenuItems()
|
addPhpActionMenuItems()
|
||||||
addItem(NSMenuItem.separator())
|
addItem(NSMenuItem.separator())
|
||||||
}
|
}
|
||||||
|
|
||||||
if PhpEnv.phpInstall != nil && Valet.installed && Preferences.isEnabled(.displayServicesManager) {
|
if PhpEnvironments.phpInstall != nil && Valet.installed && Preferences.isEnabled(.displayServicesManager) {
|
||||||
addServicesManagerMenuItem()
|
addServicesManagerMenuItem()
|
||||||
addItem(NSMenuItem.separator())
|
addItem(NSMenuItem.separator())
|
||||||
}
|
}
|
||||||
@ -28,23 +28,23 @@ class StatusMenu: NSMenu {
|
|||||||
addItem(NSMenuItem.separator())
|
addItem(NSMenuItem.separator())
|
||||||
}
|
}
|
||||||
|
|
||||||
if PhpEnv.phpInstall != nil && Preferences.isEnabled(.displayPhpConfigFinder) {
|
if PhpEnvironments.phpInstall != nil && Preferences.isEnabled(.displayPhpConfigFinder) {
|
||||||
addConfigurationMenuItems()
|
addConfigurationMenuItems()
|
||||||
addItem(NSMenuItem.separator())
|
addItem(NSMenuItem.separator())
|
||||||
}
|
}
|
||||||
|
|
||||||
if PhpEnv.phpInstall != nil && Preferences.isEnabled(.displayComposerToolkit) {
|
if PhpEnvironments.phpInstall != nil && Preferences.isEnabled(.displayComposerToolkit) {
|
||||||
addComposerMenuItems()
|
addComposerMenuItems()
|
||||||
addItem(NSMenuItem.separator())
|
addItem(NSMenuItem.separator())
|
||||||
}
|
}
|
||||||
|
|
||||||
if !PhpEnv.shared.isBusy {
|
if !PhpEnvironments.shared.isBusy {
|
||||||
if PhpEnv.phpInstall != nil && Preferences.isEnabled(.displayLimitsWidget) {
|
if PhpEnvironments.phpInstall != nil && Preferences.isEnabled(.displayLimitsWidget) {
|
||||||
addStatsMenuItem()
|
addStatsMenuItem()
|
||||||
addItem(NSMenuItem.separator())
|
addItem(NSMenuItem.separator())
|
||||||
}
|
}
|
||||||
|
|
||||||
if PhpEnv.phpInstall != nil && Preferences.isEnabled(.displayExtensions) {
|
if PhpEnvironments.phpInstall != nil && Preferences.isEnabled(.displayExtensions) {
|
||||||
addExtensionsMenuItems()
|
addExtensionsMenuItems()
|
||||||
NSMenuItem.separator()
|
NSMenuItem.separator()
|
||||||
|
|
||||||
@ -53,11 +53,11 @@ class StatusMenu: NSMenu {
|
|||||||
|
|
||||||
addPhpDoctorMenuItem()
|
addPhpDoctorMenuItem()
|
||||||
|
|
||||||
if PhpEnv.phpInstall != nil && Preferences.isEnabled(.displayPresets) {
|
if PhpEnvironments.phpInstall != nil && Preferences.isEnabled(.displayPresets) {
|
||||||
addPresetsMenuItem()
|
addPresetsMenuItem()
|
||||||
}
|
}
|
||||||
|
|
||||||
if PhpEnv.phpInstall != nil && Preferences.isEnabled(.displayMisc) {
|
if PhpEnvironments.phpInstall != nil && Preferences.isEnabled(.displayMisc) {
|
||||||
addFirstAidAndServicesMenuItems()
|
addFirstAidAndServicesMenuItems()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ class PhpGuard {
|
|||||||
var currentVersion: String?
|
var currentVersion: String?
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
guard let linked = PhpEnv.phpInstall else {
|
guard let linked = PhpEnvironments.phpInstall else {
|
||||||
Log.warn("PHP Guard is unable to determine the current PHP version!")
|
Log.warn("PHP Guard is unable to determine the current PHP version!")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -88,7 +88,7 @@ struct Preset: Codable, Equatable {
|
|||||||
applyConfigurationValue(key: conf.key, value: conf.value ?? "")
|
applyConfigurationValue(key: conf.key, value: conf.value ?? "")
|
||||||
}
|
}
|
||||||
|
|
||||||
guard let install = PhpEnv.phpInstall else {
|
guard let install = PhpEnvironments.phpInstall else {
|
||||||
Log.info("Cannot toggle extensions if no PHP version is linked.")
|
Log.info("Cannot toggle extensions if no PHP version is linked.")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -129,12 +129,12 @@ struct Preset: Codable, Equatable {
|
|||||||
// MARK: - Apply Functionality
|
// MARK: - Apply Functionality
|
||||||
|
|
||||||
private func switchToPhpVersionIfValid() async -> Bool {
|
private func switchToPhpVersionIfValid() async -> Bool {
|
||||||
if PhpEnv.shared.currentInstall?.version.short == self.version! {
|
if PhpEnvironments.shared.currentInstall?.version.short == self.version! {
|
||||||
Log.info("The version we are supposed to switch to is already active.")
|
Log.info("The version we are supposed to switch to is already active.")
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
if PhpEnv.shared.availablePhpVersions.first(where: { $0 == self.version }) != nil {
|
if PhpEnvironments.shared.availablePhpVersions.first(where: { $0 == self.version }) != nil {
|
||||||
await MainMenu.shared.switchToPhp(self.version!)
|
await MainMenu.shared.switchToPhp(self.version!)
|
||||||
return true
|
return true
|
||||||
} else {
|
} else {
|
||||||
@ -144,7 +144,7 @@ struct Preset: Codable, Equatable {
|
|||||||
subtitle: "alert.php_switch_unavailable.subtitle".localized(version!),
|
subtitle: "alert.php_switch_unavailable.subtitle".localized(version!),
|
||||||
description: "alert.php_switch_unavailable.info".localized(
|
description: "alert.php_switch_unavailable.info".localized(
|
||||||
version!,
|
version!,
|
||||||
PhpEnv.shared.availablePhpVersions.joined(separator: ", ")
|
PhpEnvironments.shared.availablePhpVersions.joined(separator: ", ")
|
||||||
)
|
)
|
||||||
).withPrimary(
|
).withPrimary(
|
||||||
text: "alert.php_switch_unavailable.ok".localized
|
text: "alert.php_switch_unavailable.ok".localized
|
||||||
@ -155,7 +155,7 @@ struct Preset: Codable, Equatable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private func applyConfigurationValue(key: String, value: String) {
|
private func applyConfigurationValue(key: String, value: String) {
|
||||||
guard let file = PhpEnv.shared.getConfigFile(forKey: key) else {
|
guard let file = PhpEnvironments.shared.getConfigFile(forKey: key) else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -218,7 +218,7 @@ struct Preset: Codable, Equatable {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
guard let install = PhpEnv.phpInstall else {
|
guard let install = PhpEnvironments.phpInstall else {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -235,7 +235,7 @@ struct Preset: Codable, Equatable {
|
|||||||
private func diffExtensions() -> [String: Bool] {
|
private func diffExtensions() -> [String: Bool] {
|
||||||
var items: [String: Bool] = [:]
|
var items: [String: Bool] = [:]
|
||||||
|
|
||||||
guard let install = PhpEnv.phpInstall else {
|
guard let install = PhpEnvironments.phpInstall else {
|
||||||
fatalError("If no PHP version is linked, diffing extensions is not possible.")
|
fatalError("If no PHP version is linked, diffing extensions is not possible.")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -257,7 +257,7 @@ struct Preset: Codable, Equatable {
|
|||||||
var items: [String: String?] = [:]
|
var items: [String: String?] = [:]
|
||||||
|
|
||||||
for (key, _) in self.configuration {
|
for (key, _) in self.configuration {
|
||||||
guard let file = PhpEnv.shared.getConfigFile(forKey: key) else {
|
guard let file = PhpEnvironments.shared.getConfigFile(forKey: key) else {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,7 +97,7 @@ struct VersionPopoverView: View {
|
|||||||
if site.isolatedPhpVersion != nil {
|
if site.isolatedPhpVersion != nil {
|
||||||
information += "alert.composer_php_isolated.desc".localized(
|
information += "alert.composer_php_isolated.desc".localized(
|
||||||
site.isolatedPhpVersion!.versionNumber.short,
|
site.isolatedPhpVersion!.versionNumber.short,
|
||||||
PhpEnv.phpInstall?.version.short ?? "???"
|
PhpEnvironments.phpInstall?.version.short ?? "???"
|
||||||
)
|
)
|
||||||
information += "\n\n"
|
information += "\n\n"
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,7 @@ struct PhpFormulaeView: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
await PhpEnv.detectPhpVersions()
|
await PhpEnvironments.detectPhpVersions()
|
||||||
await self.handler.refreshPhpVersions(loadOutdated: false)
|
await self.handler.refreshPhpVersions(loadOutdated: false)
|
||||||
await self.handler.refreshPhpVersions(loadOutdated: true)
|
await self.handler.refreshPhpVersions(loadOutdated: true)
|
||||||
self.status.busy = false
|
self.status.busy = false
|
||||||
@ -244,7 +244,7 @@ struct PhpFormulaeView: View {
|
|||||||
|
|
||||||
public func confirmUninstall(_ formula: BrewFormula) async {
|
public func confirmUninstall(_ formula: BrewFormula) async {
|
||||||
// Disallow removal of the currently active versipn
|
// Disallow removal of the currently active versipn
|
||||||
if formula.installedVersion == PhpEnv.shared.currentInstall?.version.text {
|
if formula.installedVersion == PhpEnvironments.shared.currentInstall?.version.text {
|
||||||
self.presentErrorAlert(
|
self.presentErrorAlert(
|
||||||
title: "phpman.uninstall_prevented.title".localized,
|
title: "phpman.uninstall_prevented.title".localized,
|
||||||
description: "phpman.uninstall_prevented.desc".localized,
|
description: "phpman.uninstall_prevented.desc".localized,
|
||||||
@ -297,7 +297,7 @@ struct PhpFormulaeView: View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public func setBusyStatus(_ busy: Bool) {
|
public func setBusyStatus(_ busy: Bool) {
|
||||||
PhpEnv.shared.isBusy = busy
|
PhpEnvironments.shared.isBusy = busy
|
||||||
if busy {
|
if busy {
|
||||||
Task { @MainActor in
|
Task { @MainActor in
|
||||||
MainMenu.shared.setBusyImage()
|
MainMenu.shared.setBusyImage()
|
||||||
|
@ -28,7 +28,7 @@ class PhpConfigChecker {
|
|||||||
FileExistenceCheck(condition: { Valet.installed }, path: "php-fpm.d/valet-fpm.conf")
|
FileExistenceCheck(condition: { Valet.installed }, path: "php-fpm.d/valet-fpm.conf")
|
||||||
]
|
]
|
||||||
|
|
||||||
for version in PhpEnv.shared.availablePhpVersions {
|
for version in PhpEnvironments.shared.availablePhpVersions {
|
||||||
for file in shouldExist {
|
for file in shouldExist {
|
||||||
// Early exit in case our condition is not met
|
// Early exit in case our condition is not met
|
||||||
if file.condition != nil && file.condition!() == false {
|
if file.condition != nil && file.condition!() == false {
|
||||||
|
@ -27,11 +27,11 @@ extension App {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public func onHomebrewPhpModification() async {
|
public func onHomebrewPhpModification() async {
|
||||||
// let previous = PhpEnv.shared.currentInstall?.version.text
|
// let previous = PhpEnvironments.shared.currentInstall?.version.text
|
||||||
Log.info("Something changed in the Homebrew binary directory...")
|
Log.info("Something changed in the Homebrew binary directory...")
|
||||||
await PhpEnv.detectPhpVersions()
|
await PhpEnvironments.detectPhpVersions()
|
||||||
await MainMenu.shared.refreshActiveInstallation()
|
await MainMenu.shared.refreshActiveInstallation()
|
||||||
// let new = PhpEnv.shared.currentInstall?.version.text
|
// let new = PhpEnvironments.shared.currentInstall?.version.text
|
||||||
|
|
||||||
// TODO:
|
// TODO:
|
||||||
// Check if the new and previous version are different
|
// Check if the new and previous version are different
|
||||||
|
@ -33,7 +33,7 @@ extension App {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
guard let install = PhpEnv.phpInstall else {
|
guard let install = PhpEnvironments.phpInstall else {
|
||||||
Log.info("It appears as if no PHP installation is currently active.")
|
Log.info("It appears as if no PHP installation is currently active.")
|
||||||
Log.info("The FS watcher will be disabled until a PHP install is active.")
|
Log.info("The FS watcher will be disabled until a PHP install is active.")
|
||||||
return
|
return
|
||||||
|
Reference in New Issue
Block a user