diff --git a/PHP Monitor.xcodeproj/project.pbxproj b/PHP Monitor.xcodeproj/project.pbxproj index 881b091..f9c7386 100644 --- a/PHP Monitor.xcodeproj/project.pbxproj +++ b/PHP Monitor.xcodeproj/project.pbxproj @@ -170,6 +170,15 @@ path = Preferences; sourceTree = ""; }; + 54B20EDF263AA22C00D3250E /* PHP */ = { + isa = PBXGroup; + children = ( + C41C1B4A22B019FF00E7CF16 /* PhpInstallation.swift */, + C4ACA38E25C754C100060C66 /* PhpExtension.swift */, + ); + path = PHP; + sourceTree = ""; + }; C405A4CD24B9B9070062FAFA /* IAP */ = { isa = PBXGroup; children = ( @@ -228,10 +237,11 @@ C41E181722CB61EB0072CF09 /* Domain */ = { isa = PBXGroup; children = ( - 5420395726135DB800FB00FA /* Preferences */, - C4F7808A25D7F918000DBC97 /* Terminal */, C4B13B1D25C4915000548C3A /* Core */, + 54B20EDF263AA22C00D3250E /* PHP */, + C4F7808A25D7F918000DBC97 /* Terminal */, C47331A0247093AC009A0597 /* Menu */, + 5420395726135DB800FB00FA /* Preferences */, C4811D2822D70D9C00B5F6B3 /* Helpers */, C4F8C0A222D4F100002EFE61 /* Extensions */, ); @@ -257,6 +267,7 @@ C476FF9722B0DD830098105B /* Alert.swift */, C41C1B4822B00A9800E7CF16 /* MenuBarImageGenerator.swift */, C474B00524C0E98C00066A22 /* LocalNotification.swift */, + C412E5FB25700D5300A1FB67 /* HomebrewPackage.swift */, ); path = Helpers; sourceTree = ""; @@ -266,9 +277,8 @@ children = ( C41C1B3C22B0098000E7CF16 /* Main.storyboard */, C4811D2322D70A4700B5F6B3 /* App.swift */, - C41C1B4A22B019FF00E7CF16 /* PhpInstallation.swift */, - C4ACA38E25C754C100060C66 /* PhpExtension.swift */, - C412E5FB25700D5300A1FB67 /* HomebrewPackage.swift */, + C4D8016522B1584700C6DA1B /* Startup.swift */, + C41C1B4C22B0215A00E7CF16 /* Actions.swift */, ); path = Core; sourceTree = ""; @@ -294,8 +304,6 @@ C49EAB45259FC305007F6C3B /* Paths.swift */, C42295DC2358D02000E263B2 /* Command.swift */, C41C1B4622B009A400E7CF16 /* Shell.swift */, - C4D8016522B1584700C6DA1B /* Startup.swift */, - C41C1B4C22B0215A00E7CF16 /* Actions.swift */, ); path = Terminal; sourceTree = ""; diff --git a/README.md b/README.md index 4010b6f..faffc79 100644 --- a/README.md +++ b/README.md @@ -274,7 +274,7 @@ Thank you very much for your contributions, kind words and support. ### 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. diff --git a/phpmon/Domain/Terminal/Actions.swift b/phpmon/Domain/Core/Actions.swift similarity index 100% rename from phpmon/Domain/Terminal/Actions.swift rename to phpmon/Domain/Core/Actions.swift diff --git a/phpmon/Domain/Core/App.swift b/phpmon/Domain/Core/App.swift index 8ca8ebe..07d57ec 100644 --- a/phpmon/Domain/Core/App.swift +++ b/phpmon/Domain/Core/App.swift @@ -16,10 +16,12 @@ class App { loadGlobalHotkey() } + /** Information about the currently linked PHP installation. */ static var phpInstall: PhpInstallation? { return App.shared.currentInstall } + /** Whether the app is busy doing something. Used to determine what UI to display. */ static var busy: Bool { return App.shared.busy } @@ -83,6 +85,9 @@ class App { // 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() { let hotkey = Preferences.preferences[.globalHotkey] as! String? 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() { guard let hotKey = self.shortcutHotkey else { return diff --git a/phpmon/Domain/Terminal/Startup.swift b/phpmon/Domain/Core/Startup.swift similarity index 100% rename from phpmon/Domain/Terminal/Startup.swift rename to phpmon/Domain/Core/Startup.swift diff --git a/phpmon/Domain/Core/HomebrewPackage.swift b/phpmon/Domain/Helpers/HomebrewPackage.swift similarity index 100% rename from phpmon/Domain/Core/HomebrewPackage.swift rename to phpmon/Domain/Helpers/HomebrewPackage.swift diff --git a/phpmon/Domain/Core/PhpExtension.swift b/phpmon/Domain/PHP/PhpExtension.swift similarity index 100% rename from phpmon/Domain/Core/PhpExtension.swift rename to phpmon/Domain/PHP/PhpExtension.swift diff --git a/phpmon/Domain/Core/PhpInstallation.swift b/phpmon/Domain/PHP/PhpInstallation.swift similarity index 80% rename from phpmon/Domain/Core/PhpInstallation.swift rename to phpmon/Domain/PHP/PhpInstallation.swift index d439942..068c4f9 100644 --- a/phpmon/Domain/Core/PhpInstallation.swift +++ b/phpmon/Domain/PHP/PhpInstallation.swift @@ -7,6 +7,14 @@ 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 { var version: Version! @@ -111,6 +119,14 @@ class PhpInstallation { 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() { if !self.checkPhpFpmStatus() { 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 { if self.version.short == "5.6" { // The main PHP config file should contain `valet.sock` and then we're probably fine?