Skip to content

Commit 485729f

Browse files
🚀 Version 2.3
Merge branch 'develop' into main * develop: 📝 Updated README, SECURITY docs 🍱 Updated screenshot to Big Sur ♻️ Cleanup 🚧 WIP: Notify the user about PHP switch completion (#15)
2 parents 1617b57 + 5eb36a9 commit 485729f

File tree

14 files changed

+231
-94
lines changed

14 files changed

+231
-94
lines changed

PHP Monitor.xcodeproj/project.pbxproj

+8-4
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
C46FA23F246C358E00944F05 /* StringExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = C46FA23E246C358E00944F05 /* StringExtension.swift */; };
2121
C473319F2470923A009A0597 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = C473319E2470923A009A0597 /* Localizable.strings */; };
2222
C47331A2247093B7009A0597 /* StatusMenu.swift in Sources */ = {isa = PBXBuildFile; fileRef = C47331A1247093B7009A0597 /* StatusMenu.swift */; };
23+
C474B00624C0E98C00066A22 /* LocalNotification.swift in Sources */ = {isa = PBXBuildFile; fileRef = C474B00524C0E98C00066A22 /* LocalNotification.swift */; };
2324
C476FF9822B0DD830098105B /* Alert.swift in Sources */ = {isa = PBXBuildFile; fileRef = C476FF9722B0DD830098105B /* Alert.swift */; };
2425
C4811D2422D70A4700B5F6B3 /* App.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4811D2322D70A4700B5F6B3 /* App.swift */; };
2526
C4811D2A22D70F9A00B5F6B3 /* MainMenu.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4811D2922D70F9A00B5F6B3 /* MainMenu.swift */; };
@@ -45,6 +46,7 @@
4546
C46FA23E246C358E00944F05 /* StringExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StringExtension.swift; sourceTree = "<group>"; };
4647
C473319E2470923A009A0597 /* Localizable.strings */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; path = Localizable.strings; sourceTree = "<group>"; };
4748
C47331A1247093B7009A0597 /* StatusMenu.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StatusMenu.swift; sourceTree = "<group>"; };
49+
C474B00524C0E98C00066A22 /* LocalNotification.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocalNotification.swift; sourceTree = "<group>"; };
4850
C476FF9722B0DD830098105B /* Alert.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Alert.swift; sourceTree = "<group>"; };
4951
C4811D2322D70A4700B5F6B3 /* App.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = App.swift; sourceTree = "<group>"; };
5052
C4811D2922D70F9A00B5F6B3 /* MainMenu.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainMenu.swift; sourceTree = "<group>"; };
@@ -161,6 +163,7 @@
161163
C476FF9722B0DD830098105B /* Alert.swift */,
162164
C41C1B4A22B019FF00E7CF16 /* PhpVersion.swift */,
163165
C41C1B4822B00A9800E7CF16 /* MenuBarImageGenerator.swift */,
166+
C474B00524C0E98C00066A22 /* LocalNotification.swift */,
164167
);
165168
path = Helpers;
166169
sourceTree = "<group>";
@@ -258,6 +261,7 @@
258261
C41C1B3722B0097F00E7CF16 /* AppDelegate.swift in Sources */,
259262
C41C1B4B22B019FF00E7CF16 /* PhpVersion.swift in Sources */,
260263
C476FF9822B0DD830098105B /* Alert.swift in Sources */,
264+
C474B00624C0E98C00066A22 /* LocalNotification.swift in Sources */,
261265
C47331A2247093B7009A0597 /* StatusMenu.swift in Sources */,
262266
C46FA23F246C358E00944F05 /* StringExtension.swift in Sources */,
263267
C4EE188422D3386B00E126E5 /* Constants.swift in Sources */,
@@ -401,15 +405,15 @@
401405
CODE_SIGN_IDENTITY = "Apple Development";
402406
CODE_SIGN_STYLE = Automatic;
403407
COMBINE_HIDPI_IMAGES = YES;
404-
CURRENT_PROJECT_VERSION = 24;
408+
CURRENT_PROJECT_VERSION = 25;
405409
DEVELOPMENT_TEAM = 8M54J5J787;
406410
ENABLE_HARDENED_RUNTIME = YES;
407411
INFOPLIST_FILE = phpmon/Info.plist;
408412
LD_RUNPATH_SEARCH_PATHS = (
409413
"$(inherited)",
410414
"@executable_path/../Frameworks",
411415
);
412-
MARKETING_VERSION = 2.2;
416+
MARKETING_VERSION = 2.3;
413417
PRODUCT_BUNDLE_IDENTIFIER = com.nicoverbruggen.phpmon;
414418
PRODUCT_NAME = "$(TARGET_NAME)";
415419
PROVISIONING_PROFILE_SPECIFIER = "";
@@ -425,15 +429,15 @@
425429
CODE_SIGN_IDENTITY = "Apple Development";
426430
CODE_SIGN_STYLE = Automatic;
427431
COMBINE_HIDPI_IMAGES = YES;
428-
CURRENT_PROJECT_VERSION = 24;
432+
CURRENT_PROJECT_VERSION = 25;
429433
DEVELOPMENT_TEAM = 8M54J5J787;
430434
ENABLE_HARDENED_RUNTIME = YES;
431435
INFOPLIST_FILE = phpmon/Info.plist;
432436
LD_RUNPATH_SEARCH_PATHS = (
433437
"$(inherited)",
434438
"@executable_path/../Frameworks",
435439
);
436-
MARKETING_VERSION = 2.2;
440+
MARKETING_VERSION = 2.3;
437441
PRODUCT_BUNDLE_IDENTIFIER = com.nicoverbruggen.phpmon;
438442
PRODUCT_NAME = "$(TARGET_NAME)";
439443
PROVISIONING_PROFILE_SPECIFIER = "";

PHP Monitor.xcodeproj/xcshareddata/xcschemes/PHP Monitor.xcscheme

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
ignoresPersistentStateOnLaunch = "NO"
4040
debugDocumentVersioning = "YES"
4141
debugServiceExtension = "internal"
42+
enableGPUValidationMode = "1"
4243
allowLocationSimulation = "YES">
4344
<BuildableProductRunnable
4445
runnableDebuggingMode = "0">

README.md

+11-8
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ PHP Monitor (or phpmon) is a lightweight macOS utility app that runs on your Mac
66

77
It also gives you quick access to various useful functionality (like switching PHP versions, restarting services, accessing configuration files, and more).
88

9-
<img src="./docs/screenshot.png" width="278px" alt="phpmon screenshot"/>
9+
<img src="./docs/screenshot.png" width="362px" alt="phpmon screenshot"/>
1010

1111
For me, it comes in handy when running multiple versions of PHP with Homebrew. If you wish to be able to see at a glance which version is currently linked & active with Laravel Valet, PHP Monitor is your new best friend.
1212

13-
It's also super convenient to and switch between versions.
13+
It's also super convenient to switch between different versions of PHP, or to find your currently active .ini file!
1414

1515
## 🖥 System requirements
1616

@@ -22,12 +22,12 @@ _Please note that future versions of PHP will not work automatically, minor chan
2222

2323
## 🚀 How to install
2424

25-
You can install via Homebrew, or may download the latest [release](https://github.com/nicoverbruggen/phpmon/releases).
25+
You can install via Homebrew, or may download the latest [release][1].
2626

2727
To install via Homebrew, run:
2828

29-
brew tap nicoverbruggen/homebrew-cask
30-
brew cask install phpmon
29+
brew tap nicoverbruggen/homebrew-cask
30+
brew cask install phpmon
3131

3232
## 👨‍💻 Why I built this
3333

@@ -54,7 +54,7 @@ This means:
5454
The utility runs the following commands:
5555

5656
- Unlink all detected PHP versions
57-
- Switch to PHP 7.4 (this is done in order to ensure that Valet works, even when attempting to use PHP 5.6)
57+
- Switch to PHP 7.4 (this is done to ensure that Valet works, even when attempting to use PHP 5.6)
5858
- Stop all php-fpm service instances
5959
- Link the desired version of PHP
6060
- Start the correct php-fpm service for the desired PHP version
@@ -82,8 +82,11 @@ Follow instructions as specified in the alert in order to resolve any issues.
8282

8383
## 📝 Additional information
8484

85-
Please consult the [additional information](docs/ADDITIONAL.md) file that contains more information.
85+
Please consult the [additional information][2] file that contains more information.
8686

8787
## ⭐️ Is this helpful?
8888

89-
If this software has been useful to you, star the repository so I know that the software is being used. I did not include any tracking or analytics software, so if you encounter issues, let me know via an issue.
89+
If this software has been useful to you, star the repository, so I know that the software is being used. I did not include any tracking or analytics software, so if you encounter issues, let me know via an issue.
90+
91+
[1]: https://github.com/nicoverbruggen/phpmon/releases
92+
[2]: docs/ADDITIONAL.md

SECURITY.md

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Security Policy
2+
3+
## Supported Versions
4+
5+
The following versions of PHP Monitor are supported:
6+
7+
| Version | Supported | Runs on macOS |
8+
| ------- | ------------------ | ----- |
9+
| 2.1 || Catalina (10.15), Big Sur (11.0) |
10+
| < 2.1 || Catalina (10.15) |
11+
12+
## Reporting a Vulnerability
13+
14+
Contact Nico Verbruggen at the email address used for the commits in the repository. Please include "PHP Monitor" in the subject.

docs/RELEASE.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Release Procedure
22

3-
1. Merge into `master`
3+
1. Merge into `main`
44
2. Create tag
55
3. Add changes to changelog
66
4. Archive
@@ -10,4 +10,4 @@
1010
8. Calculate SHA256: `openssl dgst -sha256 phpmon-2.x.zip`
1111
9. Upload to GitHub
1212
10. Update Cask
13-
11. Check new version can be installed via Cask
13+
11. Check new version can be installed via Cask

docs/screenshot.png

-320 KB
Loading

phpmon/AppDelegate.swift

+40-5
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,37 @@
77
//
88

99
import Cocoa
10+
import UserNotifications
1011

1112
@NSApplicationMain
12-
class AppDelegate: NSObject, NSApplicationDelegate {
13+
class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDelegate {
1314

1415
// MARK: - Variables
1516

17+
/**
18+
The Shell singleton that keeps track of the history of all
19+
(invoked by PHP Monitor) shell commands. It is used to
20+
invoke all commands in this application.
21+
*/
1622
let sharedShell : Shell
23+
24+
/**
25+
The App singleton contains information about the state of
26+
the application and global variables.
27+
*/
1728
let state : App
29+
30+
/**
31+
The MainMenu singleton is responsible for rendering the
32+
menu bar item and its menu, as well as its actions.
33+
*/
1834
let menu : MainMenu
1935

2036
// MARK: - Initializer
2137

38+
/**
39+
When the application initializes, create all singletons.
40+
*/
2241
override init() {
2342
self.sharedShell = Shell.user
2443
self.state = App.shared
@@ -27,13 +46,29 @@ class AppDelegate: NSObject, NSApplicationDelegate {
2746
}
2847

2948
// MARK: - Lifecycle
30-
49+
50+
/**
51+
When the application has finished launching, we'll want to set up
52+
the user notification center delegate, and kickoff the menu
53+
startup procedure.
54+
*/
3155
func applicationDidFinishLaunching(_ aNotification: Notification) {
56+
NSUserNotificationCenter.default.delegate = self
3257
self.menu.startup()
3358
}
3459

35-
func applicationWillTerminate(_ aNotification: Notification) {
36-
self.state.windowController = nil
60+
// MARK: - NSUserNotificationCenterDelegate
61+
62+
/**
63+
When a notification is sent, the delegate of the notification center
64+
is asked whether the notification should be presented or not. Since
65+
the user can now disable notifications per application since macOS
66+
Catalina, any and all notifications should be displayed.
67+
*/
68+
func userNotificationCenter(
69+
_ center: NSUserNotificationCenter,
70+
shouldPresent notification: NSUserNotification
71+
) -> Bool {
72+
return true
3773
}
3874
}
39-
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//
2+
// LocalNotification.swift
3+
// PHP Monitor
4+
//
5+
// Created by Nico Verbruggen on 16/07/2020.
6+
// Copyright © 2020 Nico Verbruggen. All rights reserved.
7+
//
8+
9+
import Foundation
10+
11+
class LocalNotification {
12+
public static func send(title: String, subtitle: String)
13+
{
14+
let notification = NSUserNotification()
15+
notification.title = title
16+
notification.subtitle = subtitle
17+
NSUserNotificationCenter.default.deliver(notification)
18+
}
19+
}

phpmon/Classes/Menu/StatusMenu.swift

+19-18
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,18 @@ class StatusMenu : NSMenu {
1212

1313
public func addPhpVersionMenuItems()
1414
{
15-
var string = "We are not sure what version of PHP you are running."
15+
var string = "mi_unsure".localized
1616
if (App.shared.currentVersion != nil) {
1717
if (!App.shared.currentVersion!.error) {
18-
string = "You are running PHP \(App.shared.currentVersion!.long)"
18+
// in case the php version loaded without issue
19+
string = "\("mi_php_version".localized) \(App.shared.currentVersion!.long)"
1920
self.addItem(NSMenuItem(title: string, action: nil, keyEquivalent: ""))
2021
} else {
2122
// in case of an error show the error message
22-
self.addItem(NSMenuItem(title: "Oof! It appears your PHP installation is broken...", action: nil, keyEquivalent: ""))
23-
self.addItem(NSMenuItem(title: "Try running `php -v` in your terminal.", action: nil, keyEquivalent: ""))
24-
self.addItem(NSMenuItem(title: "You could also try switching to another version.", action: nil, keyEquivalent: ""))
25-
self.addItem(NSMenuItem(title: "Running `brew reinstall php` (or for the equivalent version) might help.", action: nil, keyEquivalent: ""))
23+
["mi_php_broken_1", "mi_php_broken_2",
24+
"mi_php_broken_3", "mi_php_broken_4"].forEach { (message) in
25+
self.addItem(NSMenuItem(title: message.localized, action: nil, keyEquivalent: ""))
26+
}
2627
}
2728
}
2829
}
@@ -34,30 +35,30 @@ class StatusMenu : NSMenu {
3435
for index in (0..<App.shared.availablePhpVersions.count).reversed() {
3536
let version = App.shared.availablePhpVersions[index]
3637
let action = #selector(MainMenu.switchToPhpVersion(sender:))
37-
let menuItem = NSMenuItem(title: "Switch to PHP \(version)", action: (version == App.shared.currentVersion?.short) ? nil : action, keyEquivalent: "\(shortcutKey)")
38+
let menuItem = NSMenuItem(title: "\("mi_php_switch".localized) \(version)", action: (version == App.shared.currentVersion?.short) ? nil : action, keyEquivalent: "\(shortcutKey)")
3839
menuItem.tag = index
3940
shortcutKey = shortcutKey + 1
4041
self.addItem(menuItem)
4142
}
4243
self.addItem(NSMenuItem.separator())
43-
self.addItem(NSMenuItem(title: "Active Services", action: nil, keyEquivalent: ""))
44-
self.addItem(NSMenuItem(title: "Restart php-fpm service", action: #selector(MainMenu.restartPhpFpm), keyEquivalent: "f"))
45-
self.addItem(NSMenuItem(title: "Restart nginx service", action: #selector(MainMenu.restartNginx), keyEquivalent: "n"))
46-
self.addItem(NSMenuItem(title: "Force load latest PHP version", action: #selector(MainMenu.forceRestartLatestPhp), keyEquivalent: ""))
44+
self.addItem(NSMenuItem(title: "mi_active_services".localized, action: nil, keyEquivalent: ""))
45+
self.addItem(NSMenuItem(title: "mi_restart_php_fpm".localized, action: #selector(MainMenu.restartPhpFpm), keyEquivalent: "f"))
46+
self.addItem(NSMenuItem(title: "mi_restart_nginx".localized, action: #selector(MainMenu.restartNginx), keyEquivalent: "n"))
47+
self.addItem(NSMenuItem(title: "mi_force_load_latest".localized, action: #selector(MainMenu.forceRestartLatestPhp), keyEquivalent: ""))
4748
}
4849
if (App.shared.busy) {
49-
self.addItem(NSMenuItem(title: "PHP Monitor is busy...", action: nil, keyEquivalent: ""))
50+
self.addItem(NSMenuItem(title: "mi_busy".localized, action: nil, keyEquivalent: ""))
5051
}
5152
}
5253

5354
public func addPhpConfigurationMenuItems()
5455
{
5556
if (App.shared.currentVersion != nil) {
56-
self.addItem(NSMenuItem(title: "Configuration", action: nil, keyEquivalent: ""))
57-
self.addItem(NSMenuItem(title: "Valet configuration (.config/valet)", action: #selector(MainMenu.openValetConfigFolder), keyEquivalent: "v"))
58-
self.addItem(NSMenuItem(title: "PHP configuration file (php.ini)", action: #selector(MainMenu.openActiveConfigFolder), keyEquivalent: "c"))
57+
self.addItem(NSMenuItem(title: "mi_configuration".localized, action: nil, keyEquivalent: ""))
58+
self.addItem(NSMenuItem(title: "mi_valet_config".localized, action: #selector(MainMenu.openValetConfigFolder), keyEquivalent: "v"))
59+
self.addItem(NSMenuItem(title: "mi_php_config".localized, action: #selector(MainMenu.openActiveConfigFolder), keyEquivalent: "c"))
5960
self.addItem(NSMenuItem.separator())
60-
self.addItem(NSMenuItem(title: "Enabled Extensions", action: nil, keyEquivalent: ""))
61+
self.addItem(NSMenuItem(title: "mi_enabled_extensions".localized, action: nil, keyEquivalent: ""))
6162
self.addXdebugMenuItem()
6263
}
6364
}
@@ -68,7 +69,7 @@ class StatusMenu : NSMenu {
6869
if (xdebugFound) {
6970
let xdebugOn = App.shared.currentVersion!.xdebugEnabled
7071
let xdebugToggleMenuItem = NSMenuItem(
71-
title: "Xdebug",
72+
title: "mi_xdebug".localized,
7273
action: #selector(MainMenu.toggleXdebug), keyEquivalent: "x"
7374
)
7475
if (xdebugOn) {
@@ -77,7 +78,7 @@ class StatusMenu : NSMenu {
7778
self.addItem(xdebugToggleMenuItem)
7879
} else {
7980
let disabledItem = NSMenuItem(
80-
title: "xdebug.so missing",
81+
title: "mi_xdebug_missing".localized,
8182
action: nil, keyEquivalent: "x"
8283
)
8384
disabledItem.isEnabled = false

phpmon/Localizable.strings

+38
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,38 @@
66
Copyright © 2020 Nico Verbruggen. All rights reserved.
77
*/
88

9+
// MENU ITEMS (MI)
10+
11+
"mi_busy" = "PHP Monitor is busy...";
12+
"mi_unsure" = "We are not sure what version of PHP you are running.";
13+
"mi_php_version" = "You are running PHP";
14+
"mi_php_switch" = "Switch to PHP";
15+
"mi_php_broken_1" = "Oof! It appears your PHP installation is broken...";
16+
"mi_php_broken_2" = "Try running `php -v` in your terminal.";
17+
"mi_php_broken_3" = "You could also try switching to another version.";
18+
"mi_php_broken_4" = "Running `brew reinstall php` (or for the equivalent version) might help.";
19+
20+
"mi_active_services" = "Active Services";
21+
"mi_restart_php_fpm" = "Restart php-fpm service";
22+
"mi_restart_nginx" = "Restart nginx service";
23+
"mi_force_load_latest" = "Force load latest PHP version";
24+
25+
"mi_configuration" = "Configuration";
26+
"mi_valet_config" = "Valet configuration (.config/valet)";
27+
"mi_php_config" = "PHP Configuration file (php.ini)";
28+
"mi_enabled_extensions" = "Enabled Extensions";
29+
30+
"mi_xdebug" = "Xdebug";
31+
"mi_xdebug_missing" = "xdebug.so missing";
32+
33+
"mi_quit" = "Quit PHP Monitor";
34+
"mi_about" = "About PHP Monitor";
35+
36+
// NOTIFICATIONS
37+
38+
"notification.version_changed_title" = "PHP %@ now active";
39+
"notification.version_changed_desc" = "PHP Monitor has finished the switch to PHP %@.";
40+
941
// ALERTS
1042

1143
// Force Reload Started
@@ -15,3 +47,9 @@
1547
// Force Reload Done
1648
"alert.force_reload_done.title" = "PHP has been force reloaded";
1749
"alert.force_reload_done.info" = "All appropriate services have been restarted, and the latest version of PHP is now active. You can now try switching to another version of PHP.";
50+
51+
// PHP Monitor Cannot Start
52+
"alert.cannot_start.title" = "PHP Monitor cannot start";
53+
"alert.cannot_start.info" = "The issue you were just notified about is keeping PHP Monitor from functioning correctly. Please fix the issue and restart PHP Monitor. After clicking on OK, PHP Monitor will close.\n\nIf you have fixed the issue (or don't remember what the exact issue is) you can click on Retry, which will have PHP Monitor retry the startup checks.";
54+
"alert.cannot_start.close" = "Close";
55+
"alert.cannot_start.retry" = "Retry";

phpmon/Singletons/App.swift

-5
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,4 @@ class App {
3232
*/
3333
var timer: Timer?
3434

35-
/**
36-
The window controller that will show the log.
37-
*/
38-
var windowController: NSWindowController? = nil
39-
4035
}

0 commit comments

Comments
 (0)