diff --git a/phpmon.xcodeproj/project.pbxproj b/phpmon.xcodeproj/project.pbxproj index 039ffbe..431756a 100644 --- a/phpmon.xcodeproj/project.pbxproj +++ b/phpmon.xcodeproj/project.pbxproj @@ -17,6 +17,7 @@ C41C1B4D22B0215A00E7CF16 /* Services.swift in Sources */ = {isa = PBXBuildFile; fileRef = C41C1B4C22B0215A00E7CF16 /* Services.swift */; }; C476FF9822B0DD830098105B /* Alert.swift in Sources */ = {isa = PBXBuildFile; fileRef = C476FF9722B0DD830098105B /* Alert.swift */; }; C4D8016622B1584700C6DA1B /* BootChecks.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4D8016522B1584700C6DA1B /* BootChecks.swift */; }; + C4EE188422D3386B00E126E5 /* Constants.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4EE188322D3386B00E126E5 /* Constants.swift */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -33,6 +34,7 @@ C41C1B4C22B0215A00E7CF16 /* Services.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Services.swift; sourceTree = ""; }; C476FF9722B0DD830098105B /* Alert.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Alert.swift; sourceTree = ""; }; C4D8016522B1584700C6DA1B /* BootChecks.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BootChecks.swift; sourceTree = ""; }; + C4EE188322D3386B00E126E5 /* Constants.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Constants.swift; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -65,6 +67,7 @@ C41C1B3522B0097F00E7CF16 /* phpmon */ = { isa = PBXGroup; children = ( + C4EE188322D3386B00E126E5 /* Constants.swift */, C41E181722CB61EB0072CF09 /* Classes */, C41E181622CB61890072CF09 /* Startup */, C41E181522CB614C0072CF09 /* Terminal */, @@ -199,6 +202,7 @@ C41C1B3722B0097F00E7CF16 /* AppDelegate.swift in Sources */, C41C1B4B22B019FF00E7CF16 /* PhpVersion.swift in Sources */, C476FF9822B0DD830098105B /* Alert.swift in Sources */, + C4EE188422D3386B00E126E5 /* Constants.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/phpmon/AppDelegate.swift b/phpmon/AppDelegate.swift index b026e3b..8620e10 100644 --- a/phpmon/AppDelegate.swift +++ b/phpmon/AppDelegate.swift @@ -73,6 +73,7 @@ class AppDelegate: NSObject, NSApplicationDelegate { // Actions menu.addItem(NSMenuItem.separator()) menu.addItem(NSMenuItem(title: "Open php.ini in Finder", action: #selector(self.openActiveConfigFolder), keyEquivalent: "")) + // OPTIONAL // menu.addItem(NSMenuItem(title: "Restart PHP \(self.version!.short) service", action: #selector(self.restartPhp), keyEquivalent: "")) } menu.addItem(NSMenuItem.separator()) @@ -92,7 +93,8 @@ class AppDelegate: NSObject, NSApplicationDelegate { menu.addItem(NSMenuItem(title: "Switching PHP versions...", action: nil, keyEquivalent: "")) menu.addItem(NSMenuItem.separator()) } - menu.addItem(NSMenuItem(title: "View terminal output...", action: #selector(self.openOutput), keyEquivalent: "")) + // TODO: Enable when implementation is complete + // menu.addItem(NSMenuItem(title: "View terminal output", action: #selector(self.openOutput), keyEquivalent: "")) menu.addItem(NSMenuItem(title: "About phpmon", action: #selector(self.openAbout), keyEquivalent: "")) menu.addItem(NSMenuItem(title: "Quit phpmon", action: #selector(NSApplication.terminate(_:)), keyEquivalent: "q")) DispatchQueue.main.async { diff --git a/phpmon/Constants.swift b/phpmon/Constants.swift new file mode 100644 index 0000000..44cb21f --- /dev/null +++ b/phpmon/Constants.swift @@ -0,0 +1,26 @@ +// +// Constants.swift +// phpmon +// +// Created by Nico Verbruggen on 08/07/2019. +// Copyright © 2019 Nico Verbruggen. All rights reserved. +// + +import Cocoa + +class Constants { + + /** + * The PHP versions supported by this application. + */ + static let SupportedPhpVersions = [ + "5.6", "7.0", "7.1", "7.2", "7.3" + ] + + /** + Which php version is aliased as `php` to brew? + This is usually the latest PHP version. + */ + static let LatestPhpVersion = "7.3" + +} diff --git a/phpmon/Info.plist b/phpmon/Info.plist index 04aa118..1a9ac08 100644 --- a/phpmon/Info.plist +++ b/phpmon/Info.plist @@ -17,7 +17,7 @@ CFBundlePackageType APPL CFBundleShortVersionString - 1.1 + 1.2 CFBundleVersion 10 LSApplicationCategoryType diff --git a/phpmon/Terminal/Services.swift b/phpmon/Terminal/Services.swift index 19c3943..6591947 100644 --- a/phpmon/Terminal/Services.swift +++ b/phpmon/Terminal/Services.swift @@ -41,7 +41,11 @@ class Services { } if (availableVersions.contains("7.3")) { _ = Shell.execute(command: "brew link php@7.3") - _ = Shell.execute(command: "valet use php@\(version)") + if (version == Constants.LatestPhpVersion) { + _ = Shell.execute(command: "valet use php") + } else { + _ = Shell.execute(command: "valet use php@\(version)") + } } }