Skip to content

Commit

Permalink
🐛 Fixes #3: Bad Gateway caused by valet use
Browse files Browse the repository at this point in the history
Note: The terminal output work-in-progress is currently disabled in this
particular commit.
  • Loading branch information
nicoverbruggen committed Jul 8, 2019
1 parent 78702ae commit 1bfcdd5
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 3 deletions.
4 changes: 4 additions & 0 deletions phpmon.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand All @@ -33,6 +34,7 @@
C41C1B4C22B0215A00E7CF16 /* Services.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Services.swift; sourceTree = "<group>"; };
C476FF9722B0DD830098105B /* Alert.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Alert.swift; sourceTree = "<group>"; };
C4D8016522B1584700C6DA1B /* BootChecks.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BootChecks.swift; sourceTree = "<group>"; };
C4EE188322D3386B00E126E5 /* Constants.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Constants.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -65,6 +67,7 @@
C41C1B3522B0097F00E7CF16 /* phpmon */ = {
isa = PBXGroup;
children = (
C4EE188322D3386B00E126E5 /* Constants.swift */,
C41E181722CB61EB0072CF09 /* Classes */,
C41E181622CB61890072CF09 /* Startup */,
C41E181522CB614C0072CF09 /* Terminal */,
Expand Down Expand Up @@ -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;
};
Expand Down
4 changes: 3 additions & 1 deletion phpmon/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand All @@ -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 {
Expand Down
26 changes: 26 additions & 0 deletions phpmon/Constants.swift
Original file line number Diff line number Diff line change
@@ -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"

}
2 changes: 1 addition & 1 deletion phpmon/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.1</string>
<string>1.2</string>
<key>CFBundleVersion</key>
<string>10</string>
<key>LSApplicationCategoryType</key>
Expand Down
6 changes: 5 additions & 1 deletion phpmon/Terminal/Services.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,11 @@ class Services {
}
if (availableVersions.contains("7.3")) {
_ = Shell.execute(command: "brew link [email protected]")
_ = 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)")
}
}
}

Expand Down

0 comments on commit 1bfcdd5

Please sign in to comment.