Skip to content

Commit 1617b57

Browse files
πŸš€ Version 2.2
Merge branch 'develop' * develop: πŸ“ Update README πŸ“ Amend modal copy πŸ› Improved startup procedure 🚧 Add Internet Access Policy ✨ Add shared scheme
2 parents 9fd8e70 + 33825e7 commit 1617b57

File tree

8 files changed

+250
-38
lines changed

8 files changed

+250
-38
lines changed

β€ŽPHP Monitor.xcodeproj/project.pbxproj

+20-4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
objects = {
88

99
/* Begin PBXBuildFile section */
10+
C405A4D024B9B9140062FAFA /* InternetAccessPolicy.strings in Resources */ = {isa = PBXBuildFile; fileRef = C405A4CE24B9B9130062FAFA /* InternetAccessPolicy.strings */; };
11+
C405A4D124B9B9140062FAFA /* InternetAccessPolicy.plist in Resources */ = {isa = PBXBuildFile; fileRef = C405A4CF24B9B9140062FAFA /* InternetAccessPolicy.plist */; };
1012
C41C1B3722B0097F00E7CF16 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = C41C1B3622B0097F00E7CF16 /* AppDelegate.swift */; };
1113
C41C1B3B22B0098000E7CF16 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C41C1B3A22B0098000E7CF16 /* Assets.xcassets */; };
1214
C41C1B3E22B0098000E7CF16 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = C41C1B3C22B0098000E7CF16 /* Main.storyboard */; };
@@ -27,6 +29,8 @@
2729
/* End PBXBuildFile section */
2830

2931
/* Begin PBXFileReference section */
32+
C405A4CE24B9B9130062FAFA /* InternetAccessPolicy.strings */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; path = InternetAccessPolicy.strings; sourceTree = "<group>"; };
33+
C405A4CF24B9B9140062FAFA /* InternetAccessPolicy.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = InternetAccessPolicy.plist; sourceTree = "<group>"; };
3034
C41C1B3322B0097F00E7CF16 /* PHP Monitor.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "PHP Monitor.app"; sourceTree = BUILT_PRODUCTS_DIR; };
3135
C41C1B3622B0097F00E7CF16 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
3236
C41C1B3A22B0098000E7CF16 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
@@ -61,6 +65,15 @@
6165
/* End PBXFrameworksBuildPhase section */
6266

6367
/* Begin PBXGroup section */
68+
C405A4CD24B9B9070062FAFA /* IAP */ = {
69+
isa = PBXGroup;
70+
children = (
71+
C405A4CF24B9B9140062FAFA /* InternetAccessPolicy.plist */,
72+
C405A4CE24B9B9130062FAFA /* InternetAccessPolicy.strings */,
73+
);
74+
path = IAP;
75+
sourceTree = "<group>";
76+
};
6477
C41C1B2A22B0097F00E7CF16 = {
6578
isa = PBXGroup;
6679
children = (
@@ -91,6 +104,7 @@
91104
C41C1B4022B0098000E7CF16 /* phpmon.entitlements */,
92105
C41C1B3A22B0098000E7CF16 /* Assets.xcassets */,
93106
C473319E2470923A009A0597 /* Localizable.strings */,
107+
C405A4CD24B9B9070062FAFA /* IAP */,
94108
);
95109
path = phpmon;
96110
sourceTree = "<group>";
@@ -220,7 +234,9 @@
220234
files = (
221235
C41C1B3B22B0098000E7CF16 /* Assets.xcassets in Resources */,
222236
C41C1B3E22B0098000E7CF16 /* Main.storyboard in Resources */,
237+
C405A4D124B9B9140062FAFA /* InternetAccessPolicy.plist in Resources */,
223238
C473319F2470923A009A0597 /* Localizable.strings in Resources */,
239+
C405A4D024B9B9140062FAFA /* InternetAccessPolicy.strings in Resources */,
224240
);
225241
runOnlyForDeploymentPostprocessing = 0;
226242
};
@@ -385,15 +401,15 @@
385401
CODE_SIGN_IDENTITY = "Apple Development";
386402
CODE_SIGN_STYLE = Automatic;
387403
COMBINE_HIDPI_IMAGES = YES;
388-
CURRENT_PROJECT_VERSION = 23;
404+
CURRENT_PROJECT_VERSION = 24;
389405
DEVELOPMENT_TEAM = 8M54J5J787;
390406
ENABLE_HARDENED_RUNTIME = YES;
391407
INFOPLIST_FILE = phpmon/Info.plist;
392408
LD_RUNPATH_SEARCH_PATHS = (
393409
"$(inherited)",
394410
"@executable_path/../Frameworks",
395411
);
396-
MARKETING_VERSION = 2.1;
412+
MARKETING_VERSION = 2.2;
397413
PRODUCT_BUNDLE_IDENTIFIER = com.nicoverbruggen.phpmon;
398414
PRODUCT_NAME = "$(TARGET_NAME)";
399415
PROVISIONING_PROFILE_SPECIFIER = "";
@@ -409,15 +425,15 @@
409425
CODE_SIGN_IDENTITY = "Apple Development";
410426
CODE_SIGN_STYLE = Automatic;
411427
COMBINE_HIDPI_IMAGES = YES;
412-
CURRENT_PROJECT_VERSION = 23;
428+
CURRENT_PROJECT_VERSION = 24;
413429
DEVELOPMENT_TEAM = 8M54J5J787;
414430
ENABLE_HARDENED_RUNTIME = YES;
415431
INFOPLIST_FILE = phpmon/Info.plist;
416432
LD_RUNPATH_SEARCH_PATHS = (
417433
"$(inherited)",
418434
"@executable_path/../Frameworks",
419435
);
420-
MARKETING_VERSION = 2.1;
436+
MARKETING_VERSION = 2.2;
421437
PRODUCT_BUNDLE_IDENTIFIER = com.nicoverbruggen.phpmon;
422438
PRODUCT_NAME = "$(TARGET_NAME)";
423439
PROVISIONING_PROFILE_SPECIFIER = "";
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Scheme
3+
LastUpgradeVersion = "1150"
4+
version = "1.3">
5+
<BuildAction
6+
parallelizeBuildables = "YES"
7+
buildImplicitDependencies = "YES">
8+
<BuildActionEntries>
9+
<BuildActionEntry
10+
buildForTesting = "YES"
11+
buildForRunning = "YES"
12+
buildForProfiling = "YES"
13+
buildForArchiving = "YES"
14+
buildForAnalyzing = "YES">
15+
<BuildableReference
16+
BuildableIdentifier = "primary"
17+
BlueprintIdentifier = "C41C1B3222B0097F00E7CF16"
18+
BuildableName = "PHP Monitor.app"
19+
BlueprintName = "PHP Monitor"
20+
ReferencedContainer = "container:PHP Monitor.xcodeproj">
21+
</BuildableReference>
22+
</BuildActionEntry>
23+
</BuildActionEntries>
24+
</BuildAction>
25+
<TestAction
26+
buildConfiguration = "Debug"
27+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
28+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
29+
shouldUseLaunchSchemeArgsEnv = "YES">
30+
<Testables>
31+
</Testables>
32+
</TestAction>
33+
<LaunchAction
34+
buildConfiguration = "Debug"
35+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
36+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
37+
launchStyle = "0"
38+
useCustomWorkingDirectory = "NO"
39+
ignoresPersistentStateOnLaunch = "NO"
40+
debugDocumentVersioning = "YES"
41+
debugServiceExtension = "internal"
42+
allowLocationSimulation = "YES">
43+
<BuildableProductRunnable
44+
runnableDebuggingMode = "0">
45+
<BuildableReference
46+
BuildableIdentifier = "primary"
47+
BlueprintIdentifier = "C41C1B3222B0097F00E7CF16"
48+
BuildableName = "PHP Monitor.app"
49+
BlueprintName = "PHP Monitor"
50+
ReferencedContainer = "container:PHP Monitor.xcodeproj">
51+
</BuildableReference>
52+
</BuildableProductRunnable>
53+
</LaunchAction>
54+
<ProfileAction
55+
buildConfiguration = "Release"
56+
shouldUseLaunchSchemeArgsEnv = "YES"
57+
savedToolIdentifier = ""
58+
useCustomWorkingDirectory = "NO"
59+
debugDocumentVersioning = "YES">
60+
<BuildableProductRunnable
61+
runnableDebuggingMode = "0">
62+
<BuildableReference
63+
BuildableIdentifier = "primary"
64+
BlueprintIdentifier = "C41C1B3222B0097F00E7CF16"
65+
BuildableName = "PHP Monitor.app"
66+
BlueprintName = "PHP Monitor"
67+
ReferencedContainer = "container:PHP Monitor.xcodeproj">
68+
</BuildableReference>
69+
</BuildableProductRunnable>
70+
</ProfileAction>
71+
<AnalyzeAction
72+
buildConfiguration = "Debug">
73+
</AnalyzeAction>
74+
<ArchiveAction
75+
buildConfiguration = "Release"
76+
revealArchiveInOrganizer = "YES">
77+
</ArchiveAction>
78+
</Scheme>

β€ŽREADME.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# PHP Monitor
22

3+
<img src="./phpmon/Assets.xcassets/AppIcon.appiconset/[email protected]" alt="phpmon icon" width="128px" />
4+
35
PHP Monitor (or phpmon) is a lightweight macOS utility app that runs on your Mac and displays the active PHP version in your status bar.
46

57
It also gives you quick access to various useful functionality (like switching PHP versions, restarting services, accessing configuration files, and more).
@@ -12,7 +14,7 @@ It's also super convenient to and switch between versions.
1214

1315
## πŸ–₯ System requirements
1416

15-
* macOS 10.15 Catalina
17+
* macOS 10.15 Catalina or higher (works on macOS 11 Big Sur)
1618
* PHP 7.4 installed with Homebrew 2.x
1719
* Laravel Valet 2.x
1820

β€Žphpmon/Classes/Commands/Startup.swift

+56-16
Original file line numberDiff line numberDiff line change
@@ -10,62 +10,102 @@ import Foundation
1010

1111
class Startup {
1212

13-
public static func checkEnvironment()
13+
public var failed : Bool = false
14+
public var failureCallback = {}
15+
16+
/**
17+
Checks the user's environment and checks if PHP Monitor can be used properly.
18+
This checks if PHP is installed, Valet is running, the appropriate permissions are set, and more.
19+
20+
- Parameter success: Callback that is fired if the application can proceed with launch
21+
- Parameter failure: Callback that is fired if the application must retry launch
22+
*/
23+
public func checkEnvironment(success: () -> Void, failure: @escaping () -> Void)
1424
{
15-
self.presentAlertOnMainThreadIf(
25+
self.failureCallback = failure
26+
27+
self.performEnvironmentCheck(
1628
!Shell.user.pipe("which php").contains("/usr/local/bin/php"),
1729
messageText: "PHP is not correctly installed",
18-
informativeText: "You must install PHP via brew. Try running `which php` in Terminal, it should return `/usr/local/bin/php`. The app will not work correctly until you resolve this issue. (Usually `brew link php` resolves this issue.)"
30+
informativeText: "You must install PHP via brew. Try running `which php` in Terminal, it should return `/usr/local/bin/php`. The app will not work correctly until you resolve this issue. (Usually `brew link php` resolves this issue.)",
31+
breaking: true
1932
)
2033

21-
self.presentAlertOnMainThreadIf(
34+
self.performEnvironmentCheck(
2235
!Shell.user.pipe("ls /usr/local/opt | grep [email protected]").contains("[email protected]"),
2336
messageText: "PHP 7.4 is not correctly installed",
24-
informativeText: "PHP 7.4 alias was not found in `/usr/local/opt`. The app will not work correctly until you resolve this issue. If you already have the `php` formula installed, you may need to run `brew install [email protected]` in order for PHP Monitor to detect this installation."
37+
informativeText: "PHP 7.4 alias was not found in `/usr/local/opt`. The app will not work correctly until you resolve this issue. If you already have the `php` formula installed, you may need to run `brew install [email protected]` in order for PHP Monitor to detect this installation.",
38+
breaking: true
2539
)
2640

27-
self.presentAlertOnMainThreadIf(
41+
self.performEnvironmentCheck(
2842
!Shell.user.pipe("which valet").contains("/usr/local/bin/valet"),
2943
messageText: "Laravel Valet is not correctly installed",
30-
informativeText: "You must install Valet with composer. Try running `which valet` in Terminal, it should return `/usr/local/bin/valet`. The app will not work correctly until you resolve this issue."
44+
informativeText: "You must install Valet with composer. Try running `which valet` in Terminal, it should return `/usr/local/bin/valet`. The app will not work correctly until you resolve this issue.",
45+
breaking: true
3146
)
3247

33-
self.presentAlertOnMainThreadIf(
48+
self.performEnvironmentCheck(
3449
!Shell.user.pipe("cat /private/etc/sudoers.d/brew").contains("/usr/local/bin/brew"),
3550
messageText: "Brew has not been added to sudoers.d",
36-
informativeText: "You must run `sudo valet trust` to ensure Valet can start and stop services without having to use sudo every time. The app will not work correctly until you resolve this issue."
51+
informativeText: "You must run `sudo valet trust` to ensure Valet can start and stop services without having to use sudo every time. The app will not work correctly until you resolve this issue.",
52+
breaking: true
3753
)
3854

39-
self.presentAlertOnMainThreadIf(
55+
self.performEnvironmentCheck(
4056
!Shell.user.pipe("cat /private/etc/sudoers.d/valet").contains("/usr/local/bin/valet"),
4157
messageText: "Valet has not been added to sudoers.d",
42-
informativeText: "You must run `sudo valet trust` to ensure Valet can start and stop services without having to use sudo every time. The app will not work correctly until you resolve this issue."
58+
informativeText: "You must run `sudo valet trust` to ensure Valet can start and stop services without having to use sudo every time. The app will not work correctly until you resolve this issue.",
59+
breaking: true
4360
)
4461

4562
let services = Shell.user.pipe("brew services list | grep php")
46-
self.presentAlertOnMainThreadIf(
63+
self.performEnvironmentCheck(
4764
(services.countInstances(of: "started") > 1),
4865
messageText: "Multiple PHP services are active",
4966
informativeText: "This can cause php-fpm to serve a more recent version of PHP than the one you'd like to see active. Please terminate all extra PHP processes." +
5067
"\n\nThe easiest solution is to choose the option 'Force load latest PHP version' in the menu bar." +
5168
"\n\nAlternatively, you can fix this manually. You can do this by running `brew services list` and running `sudo brew services stop [email protected]` (and use the version that applies)." +
5269
"\n\nPHP Monitor usually handles the starting and stopping of these services, so once the correct version is the only PHP version running you should not have any issues. It is recommended to restart PHP Monitor once you have resolved this issue." +
53-
"\n\nFor more information about this issue, please see the README.md file in the repository on GitHub."
70+
"\n\nFor more information about this issue, please see the README.md file in the repository on GitHub.",
71+
breaking: false
5472
)
73+
74+
if (!self.failed) {
75+
success()
76+
}
5577
}
5678

57-
private static func presentAlertOnMainThreadIf(
79+
/**
80+
* Perform an environment check. Will cause the application to terminate, if `breaking` is set to true.
81+
*
82+
* - Parameter condition: Condition to check for
83+
* - Parameter messageText: Short description of what is wrong
84+
* - Parameter informativeText: Expanded description of the environment check that failed
85+
* - Parameter breaking: If the application should terminate afterwards
86+
*/
87+
private func performEnvironmentCheck(
5888
_ condition: Bool,
5989
messageText: String,
60-
informativeText: String
90+
informativeText: String,
91+
breaking: Bool
6192
)
6293
{
6394
if (condition) {
95+
// Only breaking issues will cause the notification
96+
if (breaking) {
97+
self.failed = true
98+
}
6499
DispatchQueue.main.async {
65-
Alert.present(
100+
// Present the information to the user
101+
_ = Alert.present(
66102
messageText: messageText,
67103
informativeText: informativeText
68104
)
105+
// Only breaking issues will throw the extra retry modal
106+
if (breaking) {
107+
self.failureCallback()
108+
}
69109
}
70110
}
71111
}

β€Žphpmon/Classes/Helpers/Alert.swift

+7-3
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,16 @@ class Alert {
1212
public static func present(
1313
messageText: String,
1414
informativeText: String,
15-
buttonTitle: String = "OK"
16-
) {
15+
buttonTitle: String = "OK",
16+
secondButtonTitle: String = ""
17+
) -> Bool {
1718
let alert = NSAlert.init()
1819
alert.messageText = messageText
1920
alert.informativeText = informativeText
2021
alert.addButton(withTitle: buttonTitle)
21-
alert.runModal()
22+
if (!secondButtonTitle.isEmpty) {
23+
alert.addButton(withTitle: secondButtonTitle)
24+
}
25+
return alert.runModal() == .alertFirstButtonReturn
2226
}
2327
}
+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>ApplicationDescription</key>
6+
<string>PHP Monitor is a tool that shows the active PHP version in your menu bar and gives you easy access to certain PHP service actions and config files.</string>
7+
<key>DeveloperName</key>
8+
<string>Nico Verbruggen</string>
9+
<key>Website</key>
10+
<string>https://github.com/nicoverbruggen/phpmon</string>
11+
<key>Connections</key>
12+
<array>
13+
<dict>
14+
<key>IsIncoming</key>
15+
<false/>
16+
<key>Host</key>
17+
<string>registry.npmjs.org</string>
18+
<key>NetworkProtocol</key>
19+
<string>TCP</string>
20+
<key>Port</key>
21+
<string>80, 443</string>
22+
<key>Relevance</key>
23+
<string>Essential</string>
24+
<key>Purpose</key>
25+
<string>PHP Monitor directly invokes Homebrew which contacts the NPM Registry.</string>
26+
<key>DenyConsequences</key>
27+
<string>If you deny these connections, PHP Monitor might not be able to complete its preset set of instructions, causing version switching to fail.</string>
28+
</dict>
29+
<dict>
30+
<key>IsIncoming</key>
31+
<false/>
32+
<key>Host</key>
33+
<string>github.com, api.github.com</string>
34+
<key>NetworkProtocol</key>
35+
<string>TCP</string>
36+
<key>Port</key>
37+
<string>443</string>
38+
<key>Relevance</key>
39+
<string>Essential</string>
40+
<key>Purpose</key>
41+
<string>PHP Monitor directly invokes Homebrew which contacts GitHub.</string>
42+
<key>DenyConsequences</key>
43+
<string>If you deny these connections, PHP Monitor might not be able to complete its preset set of instructions, causing version switching to fail.</string>
44+
</dict>
45+
</array>
46+
</dict>
47+
</plist>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// Top-level, general application description:
2+
"ApplicationDescription" = "PHP Monitor is a tool that shows the active PHP version in your menu bar and gives you easy access to certain PHP service actions and config files.";

0 commit comments

Comments
Β (0)