From f5d75de4e0cc79af9e17d521bef5b82c1fe9e5d9 Mon Sep 17 00:00:00 2001 From: yCodeTech Date: Mon, 8 Jun 2026 23:24:22 +0100 Subject: [PATCH 1/4] fix: `fetch-share-url` command bug where the `retry` helper function was undefined. Fixes #47. - Removed all the function_exists conditionals from Valet's helpers, so that they work no matter what, fixing a `PHP Fatal error: Uncaught Error: Call to undefined function Valet\retry()`. --- cli/includes/helpers.php | 106 +++++++++++++++++++-------------------- 1 file changed, 51 insertions(+), 55 deletions(-) diff --git a/cli/includes/helpers.php b/cli/includes/helpers.php index f0cf1919c..667780c45 100644 --- a/cli/includes/helpers.php +++ b/cli/includes/helpers.php @@ -179,21 +179,20 @@ function addTableSeparator($rows) { return $separatedRows; } -if (!function_exists('resolve')) { - /** - * Resolve the given class from the container. - * - * https://laravel.com/docs/12.x/helpers#method-resolve - * - * @param string $class - * - * @return mixed - */ - function resolve($class) { - return Container::getInstance()->make($class); - } +/** + * Resolve the given class from the container. + * + * https://laravel.com/docs/12.x/helpers#method-resolve + * + * @param string $class + * + * @return mixed + */ +function resolve($class) { + return Container::getInstance()->make($class); } + /** * Swap the given class implementation in the container. * @@ -204,57 +203,54 @@ function swap($class, $instance) { Container::getInstance()->instance($class, $instance); } -if (!function_exists('retry')) { - /** - * Retry the given function N times. - * - * https://laravel.com/docs/12.x/helpers#method-retry - * - * @param int $retries - * @param callable $fn - * @param int $sleep - * - * @return mixed - */ - function retry($retries, $fn, $sleep = 0) { - beginning: - try { - return $fn(); +/** + * Retry the given function N times. + * + * https://laravel.com/docs/12.x/helpers#method-retry + * + * @param int $retries + * @param callable $fn + * @param int $sleep + * + * @return mixed + */ +function retry($retries, $fn, $sleep = 0) { + beginning: + try { + return $fn(); + } + catch (Exception $e) { + if (!$retries) { + throw $e; } - catch (Exception $e) { - if (!$retries) { - throw $e; - } - - $retries--; - if ($sleep > 0) { - usleep($sleep * 1000); - } + $retries--; - goto beginning; + if ($sleep > 0) { + usleep($sleep * 1000); } + + goto beginning; } } -if (!function_exists('tap')) { - /** - * Tap the given value. - * - * https://laravel.com/docs/12.x/helpers#method-tap - * - * @param mixed $value - * @param callable $callback - * - * @return mixed - */ - function tap($value, callable $callback) { - $callback($value); +/** + * Tap the given value. + * + * https://laravel.com/docs/12.x/helpers#method-tap + * + * @param mixed $value + * @param callable $callback + * + * @return mixed + */ +function tap($value, callable $callback) { + $callback($value); - return $value; - } + return $value; } + /** * Get the user. * @@ -389,4 +385,4 @@ function str_contains_any($haystack, $needles) { } } return false; -} \ No newline at end of file +} From 51dc8d39c21aa23198a5e14425e3821426a3abf0 Mon Sep 17 00:00:00 2001 From: yCodeTech Date: Mon, 8 Jun 2026 23:25:19 +0100 Subject: [PATCH 2/4] fix: improve error messages in `currentTunnelUrl` method - Clarified the parameter description for `$site` in the docblock. - Enhanced logging and exception messages to include the site name for better debugging context. --- cli/Valet/ShareTools/ShareTool.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/cli/Valet/ShareTools/ShareTool.php b/cli/Valet/ShareTools/ShareTool.php index 9c325a526..e29e914d0 100644 --- a/cli/Valet/ShareTools/ShareTool.php +++ b/cli/Valet/ShareTools/ShareTool.php @@ -72,12 +72,12 @@ abstract public function getConfig(); /** * Get the current tunnel URL from the API. * - * @param string $site The site + * @param string $site The site that is being shared. * * @return string The current tunnel URL */ public function currentTunnelUrl(string $site) { - info("Trying to retrieve tunnel URL..."); + info("Trying to retrieve tunnel URL for '$site'..."); foreach ($this->tunnelsEndpoints as $endpoint) { try { @@ -97,7 +97,7 @@ public function currentTunnelUrl(string $site) { } } - throw new DomainException('Failed to retrieve tunnel URL.'); + throw new DomainException("Failed to retrieve tunnel URL for '$site'."); }, 250); // If response is NOT empty, return the response. @@ -110,13 +110,14 @@ public function currentTunnelUrl(string $site) { } } - throw new DomainException('Tunnel not established.'); + throw new DomainException("Tunnel not established for '$site'."); } /** * Find the HTTP tunnel URL from the list of tunnels. * - * @param array $tunnels + * @param array $tunnels The list of tunnels. + * @param string|null $site The site that is being shared. * * @return string|null */ From d021f5fd323b7bfc4da7436b141fc468ba5b3540 Mon Sep 17 00:00:00 2001 From: yCodeTech Date: Mon, 8 Jun 2026 23:27:15 +0100 Subject: [PATCH 3/4] fix: prevent duplicate TLD in share URL construction Removed the TLD from the site variable if it's included, to avoid issues with duplicate TLDs in the site being shared. --- cli/valet.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cli/valet.php b/cli/valet.php index d936aa549..1a23e90aa 100644 --- a/cli/valet.php +++ b/cli/valet.php @@ -947,7 +947,11 @@ return error("Option shortcuts cannot have a = immediately after them.\nPlease use a space to separate it from the value: valet share $site -o " . preg_replace("/=/", "", $options, 1) . " "); } - $url = ($site ?: strtolower(Site::host(getcwd()))) . '.' . Configuration::read()['tld']; + $tld = Configuration::read()['tld']; + // Remove the tld from the site if it's included, because it'll get added back in the URL variable and this can cause issues if it's included twice. + $site = str_replace(".$tld", "", $site); + + $url = ($site ?: strtolower(Site::host(getcwd()))) . '.' . $tld; $options = $options != null ? explode("//", $options) : []; From 1f81dd7cbe3c81db6cef94026f7566f17af77b98 Mon Sep 17 00:00:00 2001 From: yCodeTech Date: Mon, 8 Jun 2026 23:39:17 +0100 Subject: [PATCH 4/4] chore: update changelog and version to 3.4.3 --- CHANGELOG.md | 14 ++++++++++++++ cli/version.php | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 885fbb0a6..4e662e350 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,20 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased](https://github.com/yCodeTech/valet-windows/tree/master) +## [3.4.3](https://github.com/yCodeTech/valet-windows/tree/v3.4.3) - 2026-06-08 + +### Fixed + +- Fixed [#47](https://github.com/yCodeTech/valet-windows/issues/47): `fetch-share-url` command bug that spat out a PHP fatal error when `Valet\retry` helper was undefined; in [#48](https://github.com/yCodeTech/valet-windows/pull/48). + +- Fixed bug in `share` command that added the tld on to the specified site even if the site already included the tld. To prevent issues, the command will now remove the tld from the specified site before adding it back in the URL variable. + +- Fixed Valet's version, which was still at `3.4.1` in the previous release. Changed it to `3.4.3` to reflect this version. + +### Changed + +- Improved error messages in the `fetch-share-url` command to be more informative on the site it's trying to fetch the share URL for. This will help debugging. + ## [3.4.2](https://github.com/yCodeTech/valet-windows/tree/v3.4.2) - 2026-06-07 ### Fixed diff --git a/cli/version.php b/cli/version.php index 1b144b43e..2ad0c7ef4 100644 --- a/cli/version.php +++ b/cli/version.php @@ -3,4 +3,4 @@ /** * @var string $version The version of Laravel Valet Windows. */ -$version = '3.4.1'; +$version = '3.4.3'; \ No newline at end of file