mirror of
https://github.com/nicoverbruggen/phpmon.git
synced 2025-08-12 22:10:07 +02:00
👌 Move Valet-specific check to Valet class
This commit is contained in:
@@ -135,25 +135,6 @@ class ActivePhpInstallation {
|
|||||||
return (match == nil) ? "⚠️" : "\(value)B"
|
return (match == nil) ? "⚠️" : "\(value)B"
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
Determine if PHP-FPM is configured correctly.
|
|
||||||
|
|
||||||
For PHP 5.6, we'll check if `valet.sock` is included in the main `php-fpm.conf` file, but for more recent
|
|
||||||
versions of PHP, we can just check for the existence of the `valet-fpm.conf` file. If the check here fails,
|
|
||||||
that means that Valet won't work properly.
|
|
||||||
*/
|
|
||||||
func checkPhpFpmStatus() async -> Bool {
|
|
||||||
if self.version.short == "5.6" {
|
|
||||||
// The main PHP config file should contain `valet.sock` and then we're probably fine?
|
|
||||||
let fileName = "\(Paths.etcPath)/php/5.6/php-fpm.conf"
|
|
||||||
return await Shell.pipe("cat \(fileName)").out
|
|
||||||
.contains("valet.sock")
|
|
||||||
}
|
|
||||||
|
|
||||||
// Make sure to check if valet-fpm.conf exists. If it does, we should be fine :)
|
|
||||||
return FileSystem.fileExists("\(Paths.etcPath)/php/\(self.version.short)/php-fpm.d/valet-fpm.conf")
|
|
||||||
}
|
|
||||||
|
|
||||||
// MARK: - Structs
|
// MARK: - Structs
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -36,9 +36,7 @@ class Startup {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Log.line()
|
|
||||||
Log.info("Skipping \(group.name) checks!")
|
Log.info("Skipping \(group.name) checks!")
|
||||||
Log.line()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -134,7 +132,7 @@ class Startup {
|
|||||||
descriptionText: "startup.errors.php_opt.desc".localized
|
descriptionText: "startup.errors.php_opt.desc".localized
|
||||||
)
|
)
|
||||||
]),
|
]),
|
||||||
EnvironmentCheckGroup(name: "valet", condition: { return Valet.shared.installed }, checks: [
|
EnvironmentCheckGroup(name: "valet", condition: { return Valet.installed }, checks: [
|
||||||
// =================================================================================
|
// =================================================================================
|
||||||
// The Valet binary must exist.
|
// The Valet binary must exist.
|
||||||
// =================================================================================
|
// =================================================================================
|
||||||
|
@@ -83,10 +83,6 @@ class Valet {
|
|||||||
Notify the user about a non-default TLD being set.
|
Notify the user about a non-default TLD being set.
|
||||||
*/
|
*/
|
||||||
public static func notifyAboutUnsupportedTLD() {
|
public static func notifyAboutUnsupportedTLD() {
|
||||||
if !Valet.shared.installed {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if Valet.shared.config.tld != "test" && Preferences.isEnabled(.warnAboutNonStandardTLD) {
|
if Valet.shared.config.tld != "test" && Preferences.isEnabled(.warnAboutNonStandardTLD) {
|
||||||
Task { @MainActor in
|
Task { @MainActor in
|
||||||
BetterAlert().withInformation(
|
BetterAlert().withInformation(
|
||||||
@@ -129,10 +125,8 @@ class Valet {
|
|||||||
handle all PHP versions including isolation, it needs to know about all sites.
|
handle all PHP versions including isolation, it needs to know about all sites.
|
||||||
*/
|
*/
|
||||||
public func startPreloadingSites() async {
|
public func startPreloadingSites() async {
|
||||||
if Valet.shared.installed {
|
|
||||||
await self.reloadSites()
|
await self.reloadSites()
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Reloads the list of sites, assuming that the list isn't being reloaded at the time.
|
Reloads the list of sites, assuming that the list isn't being reloaded at the time.
|
||||||
@@ -221,6 +215,30 @@ class Valet {
|
|||||||
.out.contains("Composer detected issues in your platform")
|
.out.contains("Composer detected issues in your platform")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Determine if PHP-FPM is configured correctly.
|
||||||
|
|
||||||
|
For PHP 5.6, we'll check if `valet.sock` is included in the main `php-fpm.conf` file, but for more recent
|
||||||
|
versions of PHP, we can just check for the existence of the `valet-fpm.conf` file. If the check here fails,
|
||||||
|
that means that Valet won't work properly.
|
||||||
|
*/
|
||||||
|
func phpFpmConfigurationValid() async -> Bool {
|
||||||
|
guard let version = PhpEnv.shared.currentInstall?.version else {
|
||||||
|
Log.info("Cannot check PHP-FPM status: no version of PHP is active")
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
if version.short == "5.6" {
|
||||||
|
// The main PHP config file should contain `valet.sock` and then we're probably fine?
|
||||||
|
let fileName = "\(Paths.etcPath)/php/5.6/php-fpm.conf"
|
||||||
|
return await Shell.pipe("cat \(fileName)").out
|
||||||
|
.contains("valet.sock")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Make sure to check if valet-fpm.conf exists. If it does, we should be fine :)
|
||||||
|
return FileSystem.fileExists("\(Paths.etcPath)/php/\(version.short)/php-fpm.d/valet-fpm.conf")
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Returns a count of how many sites are linked and parked.
|
Returns a count of how many sites are linked and parked.
|
||||||
*/
|
*/
|
||||||
|
@@ -66,9 +66,7 @@ extension MainMenu {
|
|||||||
updatePhpVersionInStatusBar()
|
updatePhpVersionInStatusBar()
|
||||||
|
|
||||||
// Attempt to find out if PHP-FPM is broken
|
// Attempt to find out if PHP-FPM is broken
|
||||||
Log.info("Determining broken PHP-FPM...")
|
|
||||||
let installation = PhpEnv.phpInstall
|
let installation = PhpEnv.phpInstall
|
||||||
installation?.notifyAboutBrokenPhpFpm()
|
|
||||||
|
|
||||||
// Check for other problems
|
// Check for other problems
|
||||||
WarningManager.shared.evaluateWarnings()
|
WarningManager.shared.evaluateWarnings()
|
||||||
@@ -86,14 +84,19 @@ extension MainMenu {
|
|||||||
// Load the global hotkey
|
// Load the global hotkey
|
||||||
App.shared.loadGlobalHotkey()
|
App.shared.loadGlobalHotkey()
|
||||||
|
|
||||||
// Preload sites
|
if Valet.installed {
|
||||||
|
// Preload all sites
|
||||||
await Valet.shared.startPreloadingSites()
|
await Valet.shared.startPreloadingSites()
|
||||||
|
|
||||||
|
// Check if PHP-FPM is broken
|
||||||
|
await Valet.shared.notifyAboutBrokenPhpFpm()
|
||||||
|
|
||||||
// After preloading sites, check for PHP-FPM pool conflicts
|
// After preloading sites, check for PHP-FPM pool conflicts
|
||||||
HomebrewDiagnostics.checkForPhpFpmPoolConflicts()
|
HomebrewDiagnostics.checkForPhpFpmPoolConflicts()
|
||||||
|
|
||||||
// A non-default TLD is not officially supported since Valet 3.2.x
|
// A non-default TLD is not officially supported since Valet 3.2.x
|
||||||
Valet.notifyAboutUnsupportedTLD()
|
Valet.notifyAboutUnsupportedTLD()
|
||||||
|
}
|
||||||
|
|
||||||
// Find out which services are active
|
// Find out which services are active
|
||||||
Log.info("The services manager knows about \(ServicesManager.shared.services.count) services.")
|
Log.info("The services manager knows about \(ServicesManager.shared.services.count) services.")
|
||||||
|
@@ -125,6 +125,6 @@ extension MainMenu {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
Task { install.notifyAboutBrokenPhpFpm() }
|
Task { await Valet.shared.notifyAboutBrokenPhpFpm() }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
extension ActivePhpInstallation {
|
extension Valet {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
It is always possible that the system configuration for PHP-FPM has not been set up for Valet.
|
It is always possible that the system configuration for PHP-FPM has not been set up for Valet.
|
||||||
@@ -18,11 +18,8 @@ extension ActivePhpInstallation {
|
|||||||
- Important: The underlying check is `checkPhpFpmStatus`, which can be run multiple times.
|
- Important: The underlying check is `checkPhpFpmStatus`, which can be run multiple times.
|
||||||
This method actively presents a modal if said checks fails, so don't call this method too many times.
|
This method actively presents a modal if said checks fails, so don't call this method too many times.
|
||||||
*/
|
*/
|
||||||
public func notifyAboutBrokenPhpFpm() {
|
public func notifyAboutBrokenPhpFpm() async {
|
||||||
Task { // Determine whether FPM status is configured correctly in the background
|
if await Valet.shared.phpFpmConfigurationValid() {
|
||||||
let fpmStatusConfiguredCorrectly = await self.checkPhpFpmStatus()
|
|
||||||
|
|
||||||
if fpmStatusConfiguredCorrectly {
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -37,6 +34,5 @@ extension ActivePhpInstallation {
|
|||||||
.show()
|
.show()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user