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

🚚 Improved project organisation, updated README

This commit is contained in:
2021-05-03 16:52:51 +02:00
parent acfbc0b66f
commit b072ee8dec
8 changed files with 47 additions and 8 deletions

View File

@ -170,6 +170,15 @@
path = Preferences; path = Preferences;
sourceTree = "<group>"; sourceTree = "<group>";
}; };
54B20EDF263AA22C00D3250E /* PHP */ = {
isa = PBXGroup;
children = (
C41C1B4A22B019FF00E7CF16 /* PhpInstallation.swift */,
C4ACA38E25C754C100060C66 /* PhpExtension.swift */,
);
path = PHP;
sourceTree = "<group>";
};
C405A4CD24B9B9070062FAFA /* IAP */ = { C405A4CD24B9B9070062FAFA /* IAP */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
@ -228,10 +237,11 @@
C41E181722CB61EB0072CF09 /* Domain */ = { C41E181722CB61EB0072CF09 /* Domain */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
5420395726135DB800FB00FA /* Preferences */,
C4F7808A25D7F918000DBC97 /* Terminal */,
C4B13B1D25C4915000548C3A /* Core */, C4B13B1D25C4915000548C3A /* Core */,
54B20EDF263AA22C00D3250E /* PHP */,
C4F7808A25D7F918000DBC97 /* Terminal */,
C47331A0247093AC009A0597 /* Menu */, C47331A0247093AC009A0597 /* Menu */,
5420395726135DB800FB00FA /* Preferences */,
C4811D2822D70D9C00B5F6B3 /* Helpers */, C4811D2822D70D9C00B5F6B3 /* Helpers */,
C4F8C0A222D4F100002EFE61 /* Extensions */, C4F8C0A222D4F100002EFE61 /* Extensions */,
); );
@ -257,6 +267,7 @@
C476FF9722B0DD830098105B /* Alert.swift */, C476FF9722B0DD830098105B /* Alert.swift */,
C41C1B4822B00A9800E7CF16 /* MenuBarImageGenerator.swift */, C41C1B4822B00A9800E7CF16 /* MenuBarImageGenerator.swift */,
C474B00524C0E98C00066A22 /* LocalNotification.swift */, C474B00524C0E98C00066A22 /* LocalNotification.swift */,
C412E5FB25700D5300A1FB67 /* HomebrewPackage.swift */,
); );
path = Helpers; path = Helpers;
sourceTree = "<group>"; sourceTree = "<group>";
@ -266,9 +277,8 @@
children = ( children = (
C41C1B3C22B0098000E7CF16 /* Main.storyboard */, C41C1B3C22B0098000E7CF16 /* Main.storyboard */,
C4811D2322D70A4700B5F6B3 /* App.swift */, C4811D2322D70A4700B5F6B3 /* App.swift */,
C41C1B4A22B019FF00E7CF16 /* PhpInstallation.swift */, C4D8016522B1584700C6DA1B /* Startup.swift */,
C4ACA38E25C754C100060C66 /* PhpExtension.swift */, C41C1B4C22B0215A00E7CF16 /* Actions.swift */,
C412E5FB25700D5300A1FB67 /* HomebrewPackage.swift */,
); );
path = Core; path = Core;
sourceTree = "<group>"; sourceTree = "<group>";
@ -294,8 +304,6 @@
C49EAB45259FC305007F6C3B /* Paths.swift */, C49EAB45259FC305007F6C3B /* Paths.swift */,
C42295DC2358D02000E263B2 /* Command.swift */, C42295DC2358D02000E263B2 /* Command.swift */,
C41C1B4622B009A400E7CF16 /* Shell.swift */, C41C1B4622B009A400E7CF16 /* Shell.swift */,
C4D8016522B1584700C6DA1B /* Startup.swift */,
C41C1B4C22B0215A00E7CF16 /* Actions.swift */,
); );
path = Terminal; path = Terminal;
sourceTree = "<group>"; sourceTree = "<group>";

View File

@ -274,7 +274,7 @@ Thank you very much for your contributions, kind words and support.
### Loading info about PHP in the background ### Loading info about PHP in the background
This utility runs `php-config --version'` in the background periodically. It also checks your `.ini` files for extensions and loads more information about your limits (memory limit, POST limit, upload limit). This utility runs `php-config --version` in the background periodically. It also checks your `.ini` files for extensions and loads more information about your limits (memory limit, POST limit, upload limit).
In order to save power, this only happens once every 60 seconds. In order to save power, this only happens once every 60 seconds.

View File

@ -16,10 +16,12 @@ class App {
loadGlobalHotkey() loadGlobalHotkey()
} }
/** Information about the currently linked PHP installation. */
static var phpInstall: PhpInstallation? { static var phpInstall: PhpInstallation? {
return App.shared.currentInstall return App.shared.currentInstall
} }
/** Whether the app is busy doing something. Used to determine what UI to display. */
static var busy: Bool { static var busy: Bool {
return App.shared.busy return App.shared.busy
} }
@ -83,6 +85,9 @@ class App {
// MARK: - Methods // MARK: - Methods
/**
On startup, the preferences should be loaded from the .plist, and we'll enable the shortcut if it is set.
*/
private func loadGlobalHotkey() { private func loadGlobalHotkey() {
let hotkey = Preferences.preferences[.globalHotkey] as! String? let hotkey = Preferences.preferences[.globalHotkey] as! String?
if hotkey == nil { if hotkey == nil {
@ -101,6 +106,9 @@ class App {
} }
} }
/**
Sets up the action that needs to occur when the shortcut key is pressed (open the menu).
*/
private func setupGlobalHotkeyListener() { private func setupGlobalHotkeyListener() {
guard let hotKey = self.shortcutHotkey else { guard let hotKey = self.shortcutHotkey else {
return return

View File

@ -7,6 +7,14 @@
import Foundation import Foundation
/**
An installed version of PHP, that was detected by scanning the `/opt/php@version/bin` directory.
When initialized, that version's .ini files are also scanned (for active or inactive extensions).
Integrity checks can be performed to determine whether PHP-FPM is configured correctly.
- Note: Each installation has a separate version number. Using `version.short` is advisable if you want to interact with Homebrew.
*/
class PhpInstallation { class PhpInstallation {
var version: Version! var version: Version!
@ -111,6 +119,14 @@ class PhpInstallation {
return (match == nil) ? "⚠️" : "\(value)B" return (match == nil) ? "⚠️" : "\(value)B"
} }
/**
It is always possible that the system configuration for PHP-FPM has not been set up for Valet.
This can occur when a user manually installs a new PHP version, but does not run `valet install`.
In that case, we should alert the user!
- 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.
*/
public func notifyAboutBrokenPhpFpm() { public func notifyAboutBrokenPhpFpm() {
if !self.checkPhpFpmStatus() { if !self.checkPhpFpmStatus() {
DispatchQueue.main.async { DispatchQueue.main.async {
@ -122,6 +138,13 @@ class PhpInstallation {
} }
} }
/**
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.
*/
private func checkPhpFpmStatus() -> Bool { private func checkPhpFpmStatus() -> Bool {
if self.version.short == "5.6" { if self.version.short == "5.6" {
// The main PHP config file should contain `valet.sock` and then we're probably fine? // The main PHP config file should contain `valet.sock` and then we're probably fine?