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

📝 Update documentation

This commit is contained in:
2023-01-05 12:17:31 +01:00
parent df1b1c5856
commit a36c9b1563
9 changed files with 83 additions and 45 deletions

View File

@ -79,16 +79,28 @@ If you're still having issues, here's a few common questions & answers, as well
<details> <details>
<summary><strong>Which versions of PHP are supported?</strong></summary> <summary><strong>Which versions of PHP are supported?</strong></summary>
The following versions of PHP are officially supported:
<ul>
<li>PHP 7.4</li>
<li>PHP 8.0</li>
<li>PHP 8.1</li>
<li>PHP 8.2</li>
</ul>
The following versions have some support via backport and/or dev version:
<ul>
<li>PHP 5.6 (Valet 2 only)</li>
<li>PHP 7.0 (Valet 2 and 3 only)</li>
<li>PHP 7.1 (Valet 2 and 3 only)</li>
<li>PHP 7.2 (Valet 2 and 3 only)</li>
<li>PHP 7.3 (Valet 2 and 3 only)</li>
</ul>
Additionally, the following dev version is also available:
<ul> <ul>
<li>PHP 5.6 (backport + only if you are running Valet 2)</li>
<li>PHP 7.0 (backport)</li>
<li>PHP 7.1 (backport)</li>
<li>PHP 7.2 (backport)</li>
<li>PHP 7.3 (backport)</li>
<li>PHP 7.4 (backport)</li>
<li>PHP 8.0 (official support)</li>
<li>PHP 8.1 (official support)</li>
<li>PHP 8.2 (latest version)</li>
<li>PHP 8.3-dev (experimental)</li> <li>PHP 8.3-dev (experimental)</li>
</ul> </ul>
@ -96,6 +108,8 @@ For more details, consult the [constants file](https://github.com/nicoverbruggen
Backports are available via [this tap](https://github.com/shivammathur/homebrew-php). For more information about those backports, please see the next FAQ entry. Backports are available via [this tap](https://github.com/shivammathur/homebrew-php). For more information about those backports, please see the next FAQ entry.
For maximum compatibility with older PHP versions, you may wish to keep using Valet 2 or 3.
</details> </details>
<details> <details>

View File

@ -6,7 +6,7 @@ Generally speaking, only the latest version of **PHP Monitor** is supported, exc
| Version | Apple Silicon | Supported | Supported macOS | Deployment Target | Detected PHP Versions | Recommended Valet Version | | Version | Apple Silicon | Supported | Supported macOS | Deployment Target | Detected PHP Versions | Recommended Valet Version |
| ------- | ------------- | ------------------ | ----- | ----- | ----- | ---- | ------- | ------------- | ------------------ | ----- | ----- | ----- | ----
| 6.x | ✅ Universal binary | ✅ Yes | Big Sur (11.0)<br/>Monterey (12.0)<br/>Ventura (13.0) | macOS 11+ | PHP 5.6—PHP 8.2 (w/ Valet 2.x)<br/>PHP 7.0—PHP 8.2 (w/ Valet 3.x) | 3.0 recommended<br/> 2.16.2 minimum | | 6.x | ✅ Universal binary | ✅ Yes | Big Sur (11.0)<br/>Monterey (12.0)<br/>Ventura (13.0) | macOS 11+ | PHP 5.6—PHP 8.2 (w/ Valet 2.x)<br/>PHP 7.0—PHP 8.2 (w/ Valet 3.x)<br/>PHP 7.4-PHP 8.2 (w/ Valet 4.x) | 3.0 or higher recommended<br/> 2.16.2 minimum |
## Legacy versions ## Legacy versions

View File

@ -71,7 +71,7 @@ class Actions {
"services stop \(name)", "services stop \(name)",
sudo: ServicesManager.shared[name]?.formula.elevated ?? false sudo: ServicesManager.shared[name]?.formula.elevated ?? false
) )
await ServicesManager.shared.updateServices() await ServicesManager.shared.reloadServicesStatus()
} }
public static func startService(name: String) async { public static func startService(name: String) async {
@ -79,7 +79,7 @@ class Actions {
"services start \(name)", "services start \(name)",
sudo: ServicesManager.shared[name]?.formula.elevated ?? false sudo: ServicesManager.shared[name]?.formula.elevated ?? false
) )
await ServicesManager.shared.updateServices() await ServicesManager.shared.reloadServicesStatus()
} }
// MARK: - Finding Config Files // MARK: - Finding Config Files

View File

@ -40,7 +40,7 @@ class FakeServicesManager: ServicesManager {
} }
} }
override func updateServices() async { override func reloadServicesStatus() async {
await delay(seconds: 0.3) await delay(seconds: 0.3)
for formula in self.serviceWrappers { for formula in self.serviceWrappers {
@ -48,7 +48,29 @@ class FakeServicesManager: ServicesManager {
formula.isBusy = false formula.isBusy = false
} }
print("Sending the update!")
broadcastServicesUpdated() broadcastServicesUpdated()
} }
override func toggleService(named: String) async {
guard let wrapper = self[named] else {
return Log.err("The wrapper for service \(named) does not exist.")
}
wrapper.isBusy = true
Task { @MainActor in
wrapper.objectWillChange.send()
}
guard let service = wrapper.service else {
return Log.err("The actual service for wrapper \(named) is nil.")
}
await delay(seconds: 2)
service.running = !service.running
wrapper.isBusy = false
Task { @MainActor in
wrapper.objectWillChange.send()
self.objectWillChange.send()
}
}
} }

View File

@ -17,7 +17,7 @@ class ServicesManager: ObservableObject {
public static func useFake() { public static func useFake() {
ServicesManager.shared = FakeServicesManager.init( ServicesManager.shared = FakeServicesManager.init(
formulae: ["php", "nginx", "dnsmasq"], formulae: ["php", "nginx", "dnsmasq", "mysql"],
status: .loading status: .loading
) )
} }
@ -38,6 +38,7 @@ class ServicesManager: ObservableObject {
} }
let statuses = self.serviceWrappers[0...2].map { $0.status } let statuses = self.serviceWrappers[0...2].map { $0.status }
if statuses.contains(.loading) { if statuses.contains(.loading) {
return "Determining Valet status..." return "Determining Valet status..."
} }
@ -70,16 +71,25 @@ class ServicesManager: ObservableObject {
return .green return .green
} }
@available(*, deprecated, message: "Use a more specific method instead") /**
static func loadHomebrewServices() { This method is called when the system configuration has changed
// print(self.shared) and all the status of one or more services may need to be determined.
print("This method must be updated") */
public func reloadServicesStatus() async {
fatalError("This method `\(#function)` has not been implemented")
} }
public func updateServices() async { /**
fatalError("Must be implemented in child class") This method is called when a service needs to be toggled (on/off).
*/
public func toggleService(named: String) async {
fatalError("This method `\(#function)` has not been implemented")
} }
/**
This method will notify all publishers that subscribe to notifiable objects.
The notified objects include this very ServicesManager as well as any individual service instances.
*/
public func broadcastServicesUpdated() { public func broadcastServicesUpdated() {
Task { @MainActor in Task { @MainActor in
self.serviceWrappers.forEach { wrapper in self.serviceWrappers.forEach { wrapper in

View File

@ -13,10 +13,10 @@ class ValetServicesManager: ServicesManager {
super.init() super.init()
// Load the initial services state // Load the initial services state
Task { await self.updateServices() } Task { await self.reloadServicesStatus() }
} }
override func updateServices() async { override func reloadServicesStatus() async {
// TODO // TODO
} }
} }

View File

@ -74,7 +74,7 @@ extension MainMenu {
} }
if behaviours.contains(.broadcastServicesUpdate) { if behaviours.contains(.broadcastServicesUpdate) {
Task { await ServicesManager.shared.updateServices() } Task { await ServicesManager.shared.reloadServicesStatus() }
} }
if error != nil { if error != nil {

View File

@ -94,7 +94,7 @@ class MainMenu: NSObject, NSWindowDelegate, NSMenuDelegate, PhpSwitcherDelegate
self.refreshActiveInstallation() self.refreshActiveInstallation()
self.refreshIcon() self.refreshIcon()
self.rebuild() self.rebuild()
await ServicesManager.shared.updateServices() await ServicesManager.shared.reloadServicesStatus()
Log.perf("The menu has been reloaded!") Log.perf("The menu has been reloaded!")
} }
} }
@ -184,7 +184,7 @@ class MainMenu: NSObject, NSWindowDelegate, NSMenuDelegate, PhpSwitcherDelegate
// Make sure the shortcut key does not trigger this when the menu is open // Make sure the shortcut key does not trigger this when the menu is open
App.shared.shortcutHotkey?.isPaused = true App.shared.shortcutHotkey?.isPaused = true
Task { // Reload Homebrew services information asynchronously Task { // Reload Homebrew services information asynchronously
await ServicesManager.shared.updateServices() await ServicesManager.shared.reloadServicesStatus()
} }
} }

View File

@ -119,27 +119,19 @@ struct ServiceView: View {
// .buttonStyle(BlueButton()) // .buttonStyle(BlueButton())
.frame(minWidth: 70, alignment: .center) .frame(minWidth: 70, alignment: .center)
} }
if service.status == .active { if service.status == .active || service.status == .inactive {
Button { Button {
// TODO Task { await ServicesManager.shared.toggleService(named: service.name) }
print("you pressed the button")
} label: { } label: {
Image(systemName: "checkmark") Image(
.resizable() systemName: service.status == .active ? "checkmark" : "xmark"
.frame(width: 12.0, height: 12.0) )
.foregroundColor(Color("IconColorGreen")) .resizable()
} .frame(width: 12.0, height: 12.0)
.frame(width: 25, height: 25) .foregroundColor(
} service.status == .active ? Color("IconColorGreen") : Color("IconColorRed")
if service.status == .inactive { )
Button { }.frame(width: 25, height: 25)
// TODO
} label: {
Image(systemName: "xmark")
.resizable()
.frame(width: 12.0, height: 12.0)
.foregroundColor(Color("IconColorRed"))
}
} }
}.frame(minWidth: 70) }.frame(minWidth: 70)
} }