diff --git a/README.md b/README.md index fb284e9..2a81b2f 100644 --- a/README.md +++ b/README.md @@ -148,6 +148,26 @@ Make sure PHP is linked correctly: should return: `/usr/local/bin/php` (or `/opt/homebrew/bin/php` if you are on Apple Silicon) composer global require laravel/valet + +For optimal results, you should lock your PHP platform for global dependencies to the oldest version of PHP you intend to run. If that version is PHP 7.0, your `~/.composer/composer.json` file could look like this (please adjust the version accordingly!): + +``` +{ + "require": { + "laravel/valet": "^3.0", + }, + "config": { + "platform": { + "php": "7.0" + } + } +} +``` + +Run `composer global update` again. This ensures that when you switch to a different global PHP version, [Valet won't break](https://github.com/nicoverbruggen/phpmon/issues/178). If it does, PHP Monitor will let you know what you can do about this. + +Then, install Valet: + valet install This should install `dnsmasq` and set up Valet. Great, almost there! diff --git a/phpmon/Common/Extensions/NSWindowExtension.swift b/phpmon/Common/Extensions/NSWindowExtension.swift index 1e0d91c..1556eff 100644 --- a/phpmon/Common/Extensions/NSWindowExtension.swift +++ b/phpmon/Common/Extensions/NSWindowExtension.swift @@ -11,6 +11,20 @@ import Cocoa extension NSWindow { + /** + Centers a window. Taken from: https://stackoverflow.com/a/66140320 + */ + public func setCenterPosition(offsetY: CGFloat = 0) { + if let screenSize = screen?.visibleFrame.size { + self.setFrameOrigin( + NSPoint( + x: (screenSize.width - frame.size.width) / 2, + y: (screenSize.height - frame.size.height) / 2 + offsetY + ) + ) + } + } + /** Shakes a window. Inspired by: http://blog.ericd.net/2016/09/30/shaking-a-macos-window/ */ diff --git a/phpmon/Domain/Notice/BetterAlert.swift b/phpmon/Domain/Notice/BetterAlert.swift index b198040..d8dc6db 100644 --- a/phpmon/Domain/Notice/BetterAlert.swift +++ b/phpmon/Domain/Notice/BetterAlert.swift @@ -91,6 +91,7 @@ class BetterAlert { NSApp.activate(ignoringOtherApps: true) windowController.window?.makeKeyAndOrderFront(nil) + windowController.window?.setCenterPosition(offsetY: 70) return NSApplication.shared.runModal(for: windowController.window!) } diff --git a/phpmon/Localizable.strings b/phpmon/Localizable.strings index 28440eb..36fd8a9 100644 --- a/phpmon/Localizable.strings +++ b/phpmon/Localizable.strings @@ -446,9 +446,9 @@ You can do this by running `composer global update` in your terminal. After that "startup.errors.sudoers_valet.desc" = "If you keep seeing this error, it is possible that there is a permission issue where PHP Monitor cannot validate the file, which can usually be resolved by running: `sudo chmod +r /private/etc/sudoers.d/valet`"; /// Platform issue detected -"startup.errors.global_composer_platform_issues.title" = "Composer detected issues in your platform"; -"startup.errors.global_composer_platform_issues.subtitle" = "You will have to run `composer global update`. The easiest way to prevent this issue from occurring in the future is to:\n\n1. Run `composer global update`.\n2. Restart PHP Monitor. It should work again!\n3. Switch to the oldest PHP version you have installed.\n4. Run `composer global update` again (via the Terminal or via PHP Monitor)."; -"startup.errors.global_composer_platform_issues.desc" = "Alternatively, you can go to Preferences and check the 'Automatically update global dependencies' option. This will update your global Composer dependencies whenever you change PHP versions, so this may not be ideal if you may not have constant access to the internet.\n\nTo find out what's going wrong, try running `valet --version`. (Valet is currently not functional with the currently installed dependencies.)"; +"startup.errors.global_composer_platform_issues.title" = "PHP Monitor and Valet cannot work correctly: Composer is reporting an issue with your platform"; +"startup.errors.global_composer_platform_issues.subtitle" = "Please follow these recommended steps to avoid seeing this issue in the future:\n\n1. Run `composer global update`.\n2. Restart PHP Monitor. (It should work again.)\n3. Switch to the oldest PHP version you have installed.\n4. Run `composer global update` again."; +"startup.errors.global_composer_platform_issues.desc" = "You can go to Preferences and check the 'Automatically update global dependencies' option. This will update your global Composer dependencies whenever you change PHP versions, so this may not be ideal if you may not have constant access to the internet.\n\nTo find out exactly what's going wrong, try running `valet --version`. Valet is currently not functional with the installed dependencies. Usually this is caused by a version mismatch: i.e. installed dependencies for a newer version of PHP than the version that is currently active."; /// Cannot retrieve services "startup.errors.services_json_error.title" = "Cannot determine services status";