unlinkFromUsersBin(); $this->cli->runAsUser('ln -s "'.realpath(__DIR__.'/../../valet').'" '.$this->valetBin); } /** * Remove the symlink from the user's local bin. */ public function unlinkFromUsersBin(): void { $this->cli->quietlyAsUser('rm '.$this->valetBin); } /** * Determine if this is the latest version of Valet. * * @throws \GuzzleHttp\Exception\GuzzleException */ public function onLatestVersion(string $currentVersion): bool { $url = 'https://api.github.com/repos/laravel/valet/releases/latest'; $response = json_decode((new Client())->get($url)->getBody()); return version_compare($currentVersion, trim($response->tag_name, 'v'), '>='); } /** * Create the "sudoers.d" entry for running Valet. */ public function createSudoersEntry(): void { $this->files->ensureDirExists('/etc/sudoers.d'); $this->files->put('/etc/sudoers.d/valet', 'Cmnd_Alias VALET = '.BREW_PREFIX.'/bin/valet * %admin ALL=(root) NOPASSWD:SETENV: VALET'.PHP_EOL); } /** * Remove the "sudoers.d" entry for running Valet. */ public function removeSudoersEntry(): void { $this->cli->quietly('rm /etc/sudoers.d/valet'); } /** * Run composer global diagnose. */ public function composerGlobalDiagnose(): void { $this->cli->runAsUser('composer global diagnose'); } /** * Run composer global update. */ public function composerGlobalUpdate(): void { $this->cli->runAsUser('composer global update'); } public function forceUninstallText(): string { return 'NOTE: Valet has attempted to uninstall itself, but there are some steps you need to do manually: 1. Run php -v, and also which php, to see what PHP version you are now really using. 2. Run composer global update to update your globally-installed Composer packages to work with your default PHP. NOTE: Composer may have other dependencies for other global apps you have installed, and those may not be compatible with your default PHP. 3. Finish removing any Composer fragments of Valet: Run composer global remove laravel/valet and then rm '.BREW_PREFIX.'/bin/valet to remove the Valet bin link if it still exists. Optional: - brew list --formula will show any other Homebrew services installed, in case you want to make changes to those as well. - brew doctor can indicate if there might be any broken things left behind. - brew cleanup can purge old cached Homebrew downloads. If you had customized your Mac DNS settings in System Preferences->Network, you will need to remove 127.0.0.1 from that list. You may also want to open Keychain Access and search for valet to remove any leftover trust certificates.'; } public function uninstallText(): string { return ' You did not pass the --force parameter, so this will only return instructions on how to uninstall, not ACTUALLY uninstall anything. A --force removal WILL delete your custom configuration information, so be sure to make backups first. IF YOU WANT TO UNINSTALL VALET MANUALLY, DO THE FOLLOWING... 1. Valet Keychain Certificates Before removing Valet configuration files, we recommend that you run valet unsecure --all to clean up the certificates that Valet inserted into your Keychain. Alternatively you can do a search for @laravel.valet in Keychain Access and delete those certificates there manually. 2. Valet Configuration Files You may remove your user-specific Valet config files by running: rm -rf ~/.config/valet 3. Remove Valet package You can run composer global remove laravel/valet to uninstall the Valet package. 4. Homebrew Services You may remove the core services (php, nginx, dnsmasq) by running: brew uninstall --force php nginx dnsmasq You can then remove selected leftover configurations for these services manually in both '.BREW_PREFIX.'/etc/ and '.BREW_PREFIX.'/logs/. (If you have other PHP versions installed, run brew list --formula | grep php to see which versions you should also uninstall manually.) BEWARE: Uninstalling PHP via Homebrew will leave your Mac with its original PHP version, which may not be compatible with other Composer dependencies you have installed. As a result, you may get unexpected errors. If you have customized your Mac DNS settings in System Preferences->Network, you may need to add or remove 127.0.0.1 from the top of that list. 5. GENERAL TROUBLESHOOTING If your reasons for considering an uninstall are more for troubleshooting purposes, consider running brew doctor and/or brew cleanup to see if any problems exist there. Also consider running sudo nginx -t to test your nginx configs in case there are failures/errors there preventing nginx from running. Most of the nginx configs used by Valet are in your ~/.config/valet/Nginx directory. You might also want to investigate your global Composer configs. Helpful commands include: composer global update to apply updates to packages composer global outdated to identify outdated packages composer global diagnose to run diagnostics '; } }