mirror of
https://github.com/nicoverbruggen/phpmon.git
synced 2025-11-07 21:20:07 +01:00
✨ Detect what version of PHP the php package is linked to
This commit is contained in:
@@ -9,6 +9,7 @@
|
|||||||
/* Begin PBXBuildFile section */
|
/* Begin PBXBuildFile section */
|
||||||
C405A4D024B9B9140062FAFA /* InternetAccessPolicy.strings in Resources */ = {isa = PBXBuildFile; fileRef = C405A4CE24B9B9130062FAFA /* InternetAccessPolicy.strings */; };
|
C405A4D024B9B9140062FAFA /* InternetAccessPolicy.strings in Resources */ = {isa = PBXBuildFile; fileRef = C405A4CE24B9B9130062FAFA /* InternetAccessPolicy.strings */; };
|
||||||
C405A4D124B9B9140062FAFA /* InternetAccessPolicy.plist in Resources */ = {isa = PBXBuildFile; fileRef = C405A4CF24B9B9140062FAFA /* InternetAccessPolicy.plist */; };
|
C405A4D124B9B9140062FAFA /* InternetAccessPolicy.plist in Resources */ = {isa = PBXBuildFile; fileRef = C405A4CF24B9B9140062FAFA /* InternetAccessPolicy.plist */; };
|
||||||
|
C412E5FC25700D5300A1FB67 /* HomebrewPackage.swift in Sources */ = {isa = PBXBuildFile; fileRef = C412E5FB25700D5300A1FB67 /* HomebrewPackage.swift */; };
|
||||||
C41C1B3722B0097F00E7CF16 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = C41C1B3622B0097F00E7CF16 /* AppDelegate.swift */; };
|
C41C1B3722B0097F00E7CF16 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = C41C1B3622B0097F00E7CF16 /* AppDelegate.swift */; };
|
||||||
C41C1B3B22B0098000E7CF16 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C41C1B3A22B0098000E7CF16 /* Assets.xcassets */; };
|
C41C1B3B22B0098000E7CF16 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C41C1B3A22B0098000E7CF16 /* Assets.xcassets */; };
|
||||||
C41C1B3E22B0098000E7CF16 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = C41C1B3C22B0098000E7CF16 /* Main.storyboard */; };
|
C41C1B3E22B0098000E7CF16 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = C41C1B3C22B0098000E7CF16 /* Main.storyboard */; };
|
||||||
@@ -32,6 +33,7 @@
|
|||||||
/* Begin PBXFileReference section */
|
/* Begin PBXFileReference section */
|
||||||
C405A4CE24B9B9130062FAFA /* InternetAccessPolicy.strings */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; path = InternetAccessPolicy.strings; sourceTree = "<group>"; };
|
C405A4CE24B9B9130062FAFA /* InternetAccessPolicy.strings */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; path = InternetAccessPolicy.strings; sourceTree = "<group>"; };
|
||||||
C405A4CF24B9B9140062FAFA /* InternetAccessPolicy.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = InternetAccessPolicy.plist; sourceTree = "<group>"; };
|
C405A4CF24B9B9140062FAFA /* InternetAccessPolicy.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = InternetAccessPolicy.plist; sourceTree = "<group>"; };
|
||||||
|
C412E5FB25700D5300A1FB67 /* HomebrewPackage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomebrewPackage.swift; sourceTree = "<group>"; };
|
||||||
C41C1B3322B0097F00E7CF16 /* PHP Monitor.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "PHP Monitor.app"; sourceTree = BUILT_PRODUCTS_DIR; };
|
C41C1B3322B0097F00E7CF16 /* PHP Monitor.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "PHP Monitor.app"; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
C41C1B3622B0097F00E7CF16 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
|
C41C1B3622B0097F00E7CF16 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
|
||||||
C41C1B3A22B0098000E7CF16 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
|
C41C1B3A22B0098000E7CF16 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
|
||||||
@@ -51,6 +53,8 @@
|
|||||||
C4811D2322D70A4700B5F6B3 /* App.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = App.swift; sourceTree = "<group>"; };
|
C4811D2322D70A4700B5F6B3 /* App.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = App.swift; sourceTree = "<group>"; };
|
||||||
C4811D2922D70F9A00B5F6B3 /* MainMenu.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainMenu.swift; sourceTree = "<group>"; };
|
C4811D2922D70F9A00B5F6B3 /* MainMenu.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainMenu.swift; sourceTree = "<group>"; };
|
||||||
C4D8016522B1584700C6DA1B /* Startup.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Startup.swift; sourceTree = "<group>"; };
|
C4D8016522B1584700C6DA1B /* Startup.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Startup.swift; sourceTree = "<group>"; };
|
||||||
|
C4E713562570150F00007428 /* SECURITY.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = SECURITY.md; sourceTree = "<group>"; };
|
||||||
|
C4E713572570151400007428 /* docs */ = {isa = PBXFileReference; lastKnownFileType = folder; path = docs; sourceTree = "<group>"; };
|
||||||
C4EE188322D3386B00E126E5 /* Constants.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Constants.swift; sourceTree = "<group>"; };
|
C4EE188322D3386B00E126E5 /* Constants.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Constants.swift; sourceTree = "<group>"; };
|
||||||
C4F8C0A322D4F12C002EFE61 /* DateExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DateExtension.swift; sourceTree = "<group>"; };
|
C4F8C0A322D4F12C002EFE61 /* DateExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DateExtension.swift; sourceTree = "<group>"; };
|
||||||
C4F8C0A522D4FA41002EFE61 /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; };
|
C4F8C0A522D4FA41002EFE61 /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; };
|
||||||
@@ -80,6 +84,8 @@
|
|||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
C4F8C0A522D4FA41002EFE61 /* README.md */,
|
C4F8C0A522D4FA41002EFE61 /* README.md */,
|
||||||
|
C4E713562570150F00007428 /* SECURITY.md */,
|
||||||
|
C4E713572570151400007428 /* docs */,
|
||||||
C41C1B3522B0097F00E7CF16 /* phpmon */,
|
C41C1B3522B0097F00E7CF16 /* phpmon */,
|
||||||
C41C1B3422B0097F00E7CF16 /* Products */,
|
C41C1B3422B0097F00E7CF16 /* Products */,
|
||||||
);
|
);
|
||||||
@@ -164,6 +170,7 @@
|
|||||||
C41C1B4A22B019FF00E7CF16 /* PhpVersion.swift */,
|
C41C1B4A22B019FF00E7CF16 /* PhpVersion.swift */,
|
||||||
C41C1B4822B00A9800E7CF16 /* MenuBarImageGenerator.swift */,
|
C41C1B4822B00A9800E7CF16 /* MenuBarImageGenerator.swift */,
|
||||||
C474B00524C0E98C00066A22 /* LocalNotification.swift */,
|
C474B00524C0E98C00066A22 /* LocalNotification.swift */,
|
||||||
|
C412E5FB25700D5300A1FB67 /* HomebrewPackage.swift */,
|
||||||
);
|
);
|
||||||
path = Helpers;
|
path = Helpers;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
@@ -258,6 +265,7 @@
|
|||||||
C4811D2422D70A4700B5F6B3 /* App.swift in Sources */,
|
C4811D2422D70A4700B5F6B3 /* App.swift in Sources */,
|
||||||
C41C1B4922B00A9800E7CF16 /* MenuBarImageGenerator.swift in Sources */,
|
C41C1B4922B00A9800E7CF16 /* MenuBarImageGenerator.swift in Sources */,
|
||||||
C4811D2A22D70F9A00B5F6B3 /* MainMenu.swift in Sources */,
|
C4811D2A22D70F9A00B5F6B3 /* MainMenu.swift in Sources */,
|
||||||
|
C412E5FC25700D5300A1FB67 /* HomebrewPackage.swift in Sources */,
|
||||||
C41C1B3722B0097F00E7CF16 /* AppDelegate.swift in Sources */,
|
C41C1B3722B0097F00E7CF16 /* AppDelegate.swift in Sources */,
|
||||||
C41C1B4B22B019FF00E7CF16 /* PhpVersion.swift in Sources */,
|
C41C1B4B22B019FF00E7CF16 /* PhpVersion.swift in Sources */,
|
||||||
C476FF9822B0DD830098105B /* Alert.swift in Sources */,
|
C476FF9822B0DD830098105B /* Alert.swift in Sources */,
|
||||||
@@ -407,7 +415,7 @@
|
|||||||
CODE_SIGN_IDENTITY = "Apple Development";
|
CODE_SIGN_IDENTITY = "Apple Development";
|
||||||
CODE_SIGN_STYLE = Automatic;
|
CODE_SIGN_STYLE = Automatic;
|
||||||
COMBINE_HIDPI_IMAGES = YES;
|
COMBINE_HIDPI_IMAGES = YES;
|
||||||
CURRENT_PROJECT_VERSION = 25;
|
CURRENT_PROJECT_VERSION = 26;
|
||||||
DEVELOPMENT_TEAM = 8M54J5J787;
|
DEVELOPMENT_TEAM = 8M54J5J787;
|
||||||
ENABLE_HARDENED_RUNTIME = YES;
|
ENABLE_HARDENED_RUNTIME = YES;
|
||||||
INFOPLIST_FILE = phpmon/Info.plist;
|
INFOPLIST_FILE = phpmon/Info.plist;
|
||||||
@@ -415,7 +423,7 @@
|
|||||||
"$(inherited)",
|
"$(inherited)",
|
||||||
"@executable_path/../Frameworks",
|
"@executable_path/../Frameworks",
|
||||||
);
|
);
|
||||||
MARKETING_VERSION = 2.4;
|
MARKETING_VERSION = 2.5;
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = com.nicoverbruggen.phpmon;
|
PRODUCT_BUNDLE_IDENTIFIER = com.nicoverbruggen.phpmon;
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
PROVISIONING_PROFILE_SPECIFIER = "";
|
PROVISIONING_PROFILE_SPECIFIER = "";
|
||||||
@@ -431,7 +439,7 @@
|
|||||||
CODE_SIGN_IDENTITY = "Apple Development";
|
CODE_SIGN_IDENTITY = "Apple Development";
|
||||||
CODE_SIGN_STYLE = Automatic;
|
CODE_SIGN_STYLE = Automatic;
|
||||||
COMBINE_HIDPI_IMAGES = YES;
|
COMBINE_HIDPI_IMAGES = YES;
|
||||||
CURRENT_PROJECT_VERSION = 25;
|
CURRENT_PROJECT_VERSION = 26;
|
||||||
DEVELOPMENT_TEAM = 8M54J5J787;
|
DEVELOPMENT_TEAM = 8M54J5J787;
|
||||||
ENABLE_HARDENED_RUNTIME = YES;
|
ENABLE_HARDENED_RUNTIME = YES;
|
||||||
INFOPLIST_FILE = phpmon/Info.plist;
|
INFOPLIST_FILE = phpmon/Info.plist;
|
||||||
@@ -439,7 +447,7 @@
|
|||||||
"$(inherited)",
|
"$(inherited)",
|
||||||
"@executable_path/../Frameworks",
|
"@executable_path/../Frameworks",
|
||||||
);
|
);
|
||||||
MARKETING_VERSION = 2.4;
|
MARKETING_VERSION = 2.5;
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = com.nicoverbruggen.phpmon;
|
PRODUCT_BUNDLE_IDENTIFIER = com.nicoverbruggen.phpmon;
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
PROVISIONING_PROFILE_SPECIFIER = "";
|
PROVISIONING_PROFILE_SPECIFIER = "";
|
||||||
|
|||||||
12
README.md
12
README.md
@@ -14,13 +14,13 @@ It's also super convenient to switch between different versions of PHP, or to fi
|
|||||||
|
|
||||||
## 🖥 System requirements
|
## 🖥 System requirements
|
||||||
|
|
||||||
PHP Monitor is a universal application that runs on Apple Silicon *and* Intel-based Macs.
|
PHP Monitor is a universal application that runs on Apple Silicon **and** Intel-based Macs.
|
||||||
|
|
||||||
* macOS 10.15 Catalina or higher (works on macOS 11 Big Sur)
|
* macOS 10.15 Catalina or higher (works on macOS 11 Big Sur)
|
||||||
* PHP 7.4 installed with Homebrew 2.x
|
* The brew formula `php` has to be installed (which version it is, is detected)
|
||||||
* Laravel Valet 2.x
|
* Laravel Valet 2.x
|
||||||
|
|
||||||
_Please note that future versions of PHP will not work automatically, minor changes are required to add support for newer versions of PHP._
|
_Please note that future versions of PHP will not work automatically, minor changes are usually required to add support for newer versions of PHP._
|
||||||
|
|
||||||
## 🚀 How to install
|
## 🚀 How to install
|
||||||
|
|
||||||
@@ -51,14 +51,14 @@ This utility will detect which PHP versions you have installed via Homebrew, and
|
|||||||
|
|
||||||
This means:
|
This means:
|
||||||
|
|
||||||
- You have at least the latest version of PHP installed (`php@7.4`)
|
- You have at least the latest version of PHP installed (`php`)
|
||||||
- You have installed Laravel Valet (`which valet` returns `/usr/local/bin/valet`)
|
- You have installed Laravel Valet (`which valet` returns `/usr/local/bin/valet`)
|
||||||
- You ran `valet trust`, which means Valet commands can be run without using sudo
|
- You ran `valet trust`, which means Valet commands can be run without using sudo
|
||||||
|
|
||||||
The utility runs the following commands:
|
The utility runs the following commands:
|
||||||
|
|
||||||
- Unlink all detected PHP versions
|
- Unlink all detected PHP versions
|
||||||
- Switch to PHP 7.4 (this is done to ensure that Valet works, even when attempting to use PHP 5.6)
|
- Switch to whatever version of PHP `php` is at (this is done to ensure that Valet works, even when attempting to use PHP 5.6)
|
||||||
- Stop all php-fpm service instances
|
- Stop all php-fpm service instances
|
||||||
- Link the desired version of PHP
|
- Link the desired version of PHP
|
||||||
- Start the correct php-fpm service for the desired PHP version
|
- Start the correct php-fpm service for the desired PHP version
|
||||||
@@ -76,7 +76,7 @@ This app isn't very complicated after all. In the end, this just (conveniently)
|
|||||||
PHP Monitor performs some integrity checks to ensure a good experience when using the app. You'll get a message telling you that PHP Monitor won't work correctly in the following scenarios:
|
PHP Monitor performs some integrity checks to ensure a good experience when using the app. You'll get a message telling you that PHP Monitor won't work correctly in the following scenarios:
|
||||||
|
|
||||||
- The PHP binary is not located in `/usr/local/bin/php`
|
- The PHP binary is not located in `/usr/local/bin/php`
|
||||||
- PHP 7.4 is missing in `/usr/local/opt`
|
- PHP is missing in `/usr/local/opt`
|
||||||
- Laravel Valet is missing in `/usr/local/bin/valet`
|
- Laravel Valet is missing in `/usr/local/bin/valet`
|
||||||
- Brew has not been added to sudoers in `/private/etc/sudoers.d/brew`
|
- Brew has not been added to sudoers in `/private/etc/sudoers.d/brew`
|
||||||
- Valet has not been added to sudoers in `/private/etc/sudoers.d/valet`
|
- Valet has not been added to sudoers in `/private/etc/sudoers.d/valet`
|
||||||
|
|||||||
@@ -6,7 +6,8 @@ The following versions of PHP Monitor are supported:
|
|||||||
|
|
||||||
| Version | Universal | Supported | Runs on macOS |
|
| Version | Universal | Supported | Runs on macOS |
|
||||||
| ------- | ------------- | ------------------ | ----- |
|
| ------- | ------------- | ------------------ | ----- |
|
||||||
| 2.4 | ✅ | ✅ | Catalina (10.15), Big Sur (11.0) |
|
| 2.5 | ✅ | ✅ | Catalina (10.15), Big Sur (11.0) |
|
||||||
|
| 2.4 | ✅ | ❌ | Catalina (10.15), Big Sur (11.0) |
|
||||||
| < 2.4 | ❌ | ❌ | Catalina (10.15) |
|
| < 2.4 | ❌ | ❌ | Catalina (10.15) |
|
||||||
|
|
||||||
## Reporting a Vulnerability
|
## Reporting a Vulnerability
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ Super convenient!
|
|||||||
|
|
||||||
#### Q: PHP Monitor says that the latest version of PHP is not installed, but it is!
|
#### Q: PHP Monitor says that the latest version of PHP is not installed, but it is!
|
||||||
|
|
||||||
Try installing again using `brew install php@7.4`.
|
Try installing again using `brew install php`.
|
||||||
|
|
||||||
This should resolve the issue.
|
This should resolve the issue.
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ class Actions {
|
|||||||
|
|
||||||
public static func restartPhpFpm() {
|
public static func restartPhpFpm() {
|
||||||
let version = App.shared.currentVersion!.short
|
let version = App.shared.currentVersion!.short
|
||||||
if (version == Constants.LatestPhpVersion) {
|
if (version == App.shared.brewPhpVersion) {
|
||||||
Shell.user.run("sudo brew services restart php")
|
Shell.user.run("sudo brew services restart php")
|
||||||
} else {
|
} else {
|
||||||
Shell.user.run("sudo brew services restart php@\(version)")
|
Shell.user.run("sudo brew services restart php@\(version)")
|
||||||
@@ -45,16 +45,16 @@ class Actions {
|
|||||||
// Unlink the current version
|
// Unlink the current version
|
||||||
Shell.user.run("brew unlink php@\(version)")
|
Shell.user.run("brew unlink php@\(version)")
|
||||||
// Stop the services
|
// Stop the services
|
||||||
if (version == Constants.LatestPhpVersion) {
|
if (version == App.shared.brewPhpVersion) {
|
||||||
Shell.user.run("sudo brew services stop php")
|
Shell.user.run("sudo brew services stop php")
|
||||||
} else {
|
} else {
|
||||||
Shell.user.run("sudo brew services stop php@\(version)")
|
Shell.user.run("sudo brew services stop php@\(version)")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (availableVersions.contains(Constants.LatestPhpVersion)) {
|
if (availableVersions.contains(App.shared.brewPhpVersion)) {
|
||||||
// Use the latest version as a default
|
// Use the latest version as a default
|
||||||
Shell.user.run("brew link php@\(Constants.LatestPhpVersion) --overwrite --force")
|
Shell.user.run("brew link php@\(App.shared.brewPhpVersion) --overwrite --force")
|
||||||
if (version == Constants.LatestPhpVersion) {
|
if (version == App.shared.brewPhpVersion) {
|
||||||
// If said version was also requested, all we need to do is start the service
|
// If said version was also requested, all we need to do is start the service
|
||||||
Shell.user.run("sudo brew services start php")
|
Shell.user.run("sudo brew services start php")
|
||||||
} else {
|
} else {
|
||||||
@@ -115,7 +115,7 @@ class Actions {
|
|||||||
let versions = self.detectPhpVersions()
|
let versions = self.detectPhpVersions()
|
||||||
versions.forEach { (version) in
|
versions.forEach { (version) in
|
||||||
Shell.user.run("brew unlink php@\(version)")
|
Shell.user.run("brew unlink php@\(version)")
|
||||||
if (version == Constants.LatestPhpVersion) {
|
if (version == App.shared.brewPhpVersion) {
|
||||||
Shell.user.run("brew services stop php")
|
Shell.user.run("brew services stop php")
|
||||||
Shell.user.run("sudo brew services stop php")
|
Shell.user.run("sudo brew services stop php")
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -32,9 +32,9 @@ class Startup {
|
|||||||
)
|
)
|
||||||
|
|
||||||
self.performEnvironmentCheck(
|
self.performEnvironmentCheck(
|
||||||
!Shell.user.pipe("ls /usr/local/opt | grep php@7.4").contains("php@7.4"),
|
!Shell.user.pipe("ls /usr/local/opt | grep php").contains("php"),
|
||||||
messageText: "PHP 7.4 is not correctly installed",
|
messageText: "PHP is not correctly installed",
|
||||||
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 php@7.4` in order for PHP Monitor to detect this installation.",
|
informativeText: "PHP 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 php` in order for PHP Monitor to detect this installation.",
|
||||||
breaking: true
|
breaking: true
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -71,14 +71,31 @@ class Startup {
|
|||||||
breaking: false
|
breaking: false
|
||||||
)
|
)
|
||||||
|
|
||||||
let brewPhpAlias = Shell.user.pipe("brew info php --json");
|
|
||||||
print(brewPhpAlias)
|
|
||||||
|
|
||||||
if (!self.failed) {
|
if (!self.failed) {
|
||||||
|
self.determineBrewAliasVersion()
|
||||||
success()
|
success()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* In order to avoid having to hard-code which version of PHP is aliased to what specific subversion,
|
||||||
|
* PHP Monitor now determines the alias by checking the user's system.
|
||||||
|
*/
|
||||||
|
private func determineBrewAliasVersion()
|
||||||
|
{
|
||||||
|
print("PHP Monitor has determined the application has successfully passed all checks.")
|
||||||
|
print("Determining which version of PHP is aliased to `php` via Homebrew...")
|
||||||
|
|
||||||
|
let brewPhpAlias = Shell.user.pipe("brew info php --json");
|
||||||
|
|
||||||
|
App.shared.brewPhpPackage = try! JSONDecoder().decode(
|
||||||
|
[HomebrewPackage].self,
|
||||||
|
from: brewPhpAlias.data(using: .utf8)!
|
||||||
|
).first!
|
||||||
|
|
||||||
|
print("When on your system, the `php` formula means version \(App.shared.brewPhpVersion)!")
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Perform an environment check. Will cause the application to terminate, if `breaking` is set to true.
|
* Perform an environment check. Will cause the application to terminate, if `breaking` is set to true.
|
||||||
*
|
*
|
||||||
|
|||||||
19
phpmon/Classes/Helpers/HomebrewPackage.swift
Normal file
19
phpmon/Classes/Helpers/HomebrewPackage.swift
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
//
|
||||||
|
// HomebrewPackage.swift
|
||||||
|
// PHP Monitor
|
||||||
|
//
|
||||||
|
// Created by Nico Verbruggen on 26/11/2020.
|
||||||
|
// Copyright © 2020 Nico Verbruggen. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
struct HomebrewPackage : Decodable {
|
||||||
|
let name: String
|
||||||
|
let full_name: String
|
||||||
|
let aliases: [String]
|
||||||
|
|
||||||
|
public func getVersion() -> String {
|
||||||
|
return aliases.first!.replacingOccurrences(of: "php@", with: "")
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -12,15 +12,17 @@ class Constants {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* The PHP versions supported by this application.
|
* The PHP versions supported by this application.
|
||||||
|
* Versions that do not appear in this array are omitted from the list.
|
||||||
*/
|
*/
|
||||||
static let SupportedPhpVersions = [
|
static let SupportedPhpVersions = [
|
||||||
"5.6", "7.0", "7.1", "7.2", "7.3", "7.4", "8.0"
|
"5.6",
|
||||||
|
"7.0",
|
||||||
|
"7.1",
|
||||||
|
"7.2",
|
||||||
|
"7.3",
|
||||||
|
"7.4",
|
||||||
|
"8.0",
|
||||||
|
"8.1"
|
||||||
]
|
]
|
||||||
|
|
||||||
/**
|
|
||||||
Which php version is aliased as `php` to brew?
|
|
||||||
This is usually the latest PHP version.
|
|
||||||
*/
|
|
||||||
static let LatestPhpVersion = "7.4"
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,7 +38,7 @@
|
|||||||
<key>Relevance</key>
|
<key>Relevance</key>
|
||||||
<string>Essential</string>
|
<string>Essential</string>
|
||||||
<key>Purpose</key>
|
<key>Purpose</key>
|
||||||
<string>PHP Monitor directly invokes Homebrew which contacts GitHub.</string>
|
<string>PHP Monitor directly invokes Homebrew which contacts GitHub. This happens when PHP Monitor asks for more information about the PHP formula to determine which version of PHP you've got running.</string>
|
||||||
<key>DenyConsequences</key>
|
<key>DenyConsequences</key>
|
||||||
<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>
|
<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>
|
||||||
</dict>
|
</dict>
|
||||||
|
|||||||
@@ -32,12 +32,24 @@ class App {
|
|||||||
*/
|
*/
|
||||||
var timer: Timer?
|
var timer: Timer?
|
||||||
|
|
||||||
|
/**
|
||||||
|
Information we were able to discern from the Homebrew info command (as JSON).
|
||||||
|
*/
|
||||||
|
var brewPhpPackage: HomebrewPackage? = nil {
|
||||||
|
didSet {
|
||||||
|
self.brewPhpVersion = self.brewPhpPackage!.getVersion()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
The version that the `php` formula via Brew is aliased to on the current system.
|
The version that the `php` formula via Brew is aliased to on the current system.
|
||||||
|
|
||||||
If you're up to date, `php` will be aliased to the latest version,
|
If you're up to date, `php` will be aliased to the latest version,
|
||||||
but that might not be the case.
|
but that might not be the case.
|
||||||
|
|
||||||
|
We'll technically default to version 8.0, but the information should always be loaded
|
||||||
|
from Homebrew itself upon starting the application.
|
||||||
*/
|
*/
|
||||||
var brewPhpAlias: String? = nil
|
var brewPhpVersion: String = "8.0"
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user