From d1ebd4304551c6973f78e55b91e7c33cdc7021fc Mon Sep 17 00:00:00 2001 From: Mischa Braam Date: Tue, 4 Apr 2023 09:32:07 +0200 Subject: [PATCH 01/68] Fix read non existing config file --- cli/Valet/Configuration.php | 5 ++++- tests/CliTest.php | 5 ++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/cli/Valet/Configuration.php b/cli/Valet/Configuration.php index 6ff70ee48..b62d9e63a 100644 --- a/cli/Valet/Configuration.php +++ b/cli/Valet/Configuration.php @@ -152,7 +152,10 @@ public function prune(): void */ public function read(): array { - return json_decode($this->files->get($this->path()), true, 512, JSON_THROW_ON_ERROR); + if ($this->files->exists($this->path())) { + return json_decode($this->files->get($this->path()), true, 512, JSON_THROW_ON_ERROR); + } + return []; } /** diff --git a/tests/CliTest.php b/tests/CliTest.php index 9bc40a06b..b2c6fdd76 100644 --- a/tests/CliTest.php +++ b/tests/CliTest.php @@ -135,13 +135,12 @@ public function test_status_command_succeeding() $brew->shouldReceive('installed')->twice()->andReturn(true); $cli = Mockery::mock(CommandLine::class); - $cli->shouldReceive('run')->once()->andReturn(true); $cli->shouldReceive('runAsUser')->once()->with('brew services info --all --json')->andReturn('[{"name":"nginx","running":true}]'); $cli->shouldReceive('run')->once()->with('brew services info --all --json')->andReturn('[{"name":"nginx","running":true},{"name":"dnsmasq","running":true},{"name":"php@8.2","running":true}]'); $files = Mockery::mock(Filesystem::class.'[exists]'); - $files->shouldReceive('exists')->once()->andReturn(true); + $files->shouldReceive('exists')->andReturn(true); swap(Brew::class, $brew); swap(CommandLine::class, $cli); @@ -168,7 +167,7 @@ public function test_status_command_failing() $cli->shouldReceive('run')->once()->with('brew services info --all --json')->andReturn('[{"name":"nginx","running":true}]'); $files = Mockery::mock(Filesystem::class.'[exists]'); - $files->shouldReceive('exists')->once()->andReturn(false); + $files->shouldReceive('exists')->andReturn(false); swap(Brew::class, $brew); swap(CommandLine::class, $cli); From 96bc080d195d18db2f09c1400ed5f6281379ec3a Mon Sep 17 00:00:00 2001 From: Dries Vints Date: Fri, 7 Apr 2023 10:58:22 +0200 Subject: [PATCH 02/68] Update and rename 1_Bug_report.md to 1_Bug_report.yml --- .github/ISSUE_TEMPLATE/1_Bug_report.md | 23 --------------- .github/ISSUE_TEMPLATE/1_Bug_report.yml | 37 +++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 23 deletions(-) delete mode 100644 .github/ISSUE_TEMPLATE/1_Bug_report.md create mode 100644 .github/ISSUE_TEMPLATE/1_Bug_report.yml diff --git a/.github/ISSUE_TEMPLATE/1_Bug_report.md b/.github/ISSUE_TEMPLATE/1_Bug_report.md deleted file mode 100644 index d2c4077c9..000000000 --- a/.github/ISSUE_TEMPLATE/1_Bug_report.md +++ /dev/null @@ -1,23 +0,0 @@ ---- -name: "Bug report" -about: 'Report a general library issue. Please ensure your version is still supported: https://laravel.com/docs/releases#support-policy' ---- - - - -### Description: - - -### Steps To Reproduce: - - -### Diagnosis - - diff --git a/.github/ISSUE_TEMPLATE/1_Bug_report.yml b/.github/ISSUE_TEMPLATE/1_Bug_report.yml new file mode 100644 index 000000000..c89346ecd --- /dev/null +++ b/.github/ISSUE_TEMPLATE/1_Bug_report.yml @@ -0,0 +1,37 @@ +name: Bug Report +description: "Report a general library issue." +body: + - type: markdown + attributes: + value: | + Before submitting your report, [please ensure your Laravel version is still supported](https://laravel.com/docs/releases#support-policy). + + Did you know? Most problems can be resolved by running 3 commands: + + - `composer self-update` + - `composer global update` + - `brew upgrade` + + ... in fact, it's good to run these commands at least once a month! + + Alternatively, try to reboot your machine first to see if it solves your current issue. + - type: textarea + attributes: + label: Description + description: Provide a detailed description of the issue you are facing. + validations: + required: true + - type: textarea + attributes: + label: Steps To Reproduce + description: Provide detailed steps to reproduce your issue. + validations: + required: true + - type: textarea + attributes: + label: Diagnosis + description: Run `valet diagnose` and then paste the output here. + validations: + required: true + + From fcfbb9829e0fb83baa741796e1c95891f4c670fe Mon Sep 17 00:00:00 2001 From: Dries Vints Date: Fri, 7 Apr 2023 10:59:07 +0200 Subject: [PATCH 03/68] Update 1_Bug_report.yml --- .github/ISSUE_TEMPLATE/1_Bug_report.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE/1_Bug_report.yml b/.github/ISSUE_TEMPLATE/1_Bug_report.yml index c89346ecd..d0d4aefb9 100644 --- a/.github/ISSUE_TEMPLATE/1_Bug_report.yml +++ b/.github/ISSUE_TEMPLATE/1_Bug_report.yml @@ -6,7 +6,7 @@ body: value: | Before submitting your report, [please ensure your Laravel version is still supported](https://laravel.com/docs/releases#support-policy). - Did you know? Most problems can be resolved by running 3 commands: + **Did you know? Most problems can be resolved by running 3 commands:** - `composer self-update` - `composer global update` From fd35343f6000814b615a1264e3436db1dd7135b9 Mon Sep 17 00:00:00 2001 From: Chris Brown Date: Mon, 24 Apr 2023 21:48:04 -0400 Subject: [PATCH 04/68] [v4] Fix ngrok.io proxy/forwarding detection Fixes #1384 Since Valet 4 uses Ngrok v3, this change is needed to accommodate the change ngrok made: > In ngrok v3 the `X-Original-Host` header was replaced with the more standard `X-Forwarded-Host` to better align with web standards. > More Info: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Forwarded-Host Credit to @streamingsystems for doing the legwork. Co-authored-by: streamingsystems --- cli/Valet/Drivers/LaravelValetDriver.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cli/Valet/Drivers/LaravelValetDriver.php b/cli/Valet/Drivers/LaravelValetDriver.php index 6322368a8..f5b8dedb4 100644 --- a/cli/Valet/Drivers/LaravelValetDriver.php +++ b/cli/Valet/Drivers/LaravelValetDriver.php @@ -18,8 +18,8 @@ public function serves(string $sitePath, string $siteName, string $uri): bool */ public function beforeLoading(string $sitePath, string $siteName, string $uri): void { - // Shortcut for getting the "local" hostname as the HTTP_HOST - if (isset($_SERVER['HTTP_X_ORIGINAL_HOST'], $_SERVER['HTTP_X_FORWARDED_HOST'])) { + // Shortcut for getting the "local" hostname as the HTTP_HOST, especially when proxied or using 'share' + if (isset($_SERVER['HTTP_X_FORWARDED_HOST'])) { $_SERVER['HTTP_HOST'] = $_SERVER['HTTP_X_FORWARDED_HOST']; } } From cbb571f7ac8a4b2f0b04ad00ae7d4aab7420758f Mon Sep 17 00:00:00 2001 From: mattstauffer Date: Wed, 26 Apr 2023 13:13:37 +0000 Subject: [PATCH 05/68] Fix code styling --- cli/Valet/Filesystem.php | 18 ++++++------ cli/Valet/Nginx.php | 2 +- cli/Valet/Site.php | 62 ++++++++++++++++++++-------------------- tests/BrewTest.php | 4 +-- 4 files changed, 43 insertions(+), 43 deletions(-) diff --git a/cli/Valet/Filesystem.php b/cli/Valet/Filesystem.php index 6e924fa94..3b16d7f94 100644 --- a/cli/Valet/Filesystem.php +++ b/cli/Valet/Filesystem.php @@ -243,12 +243,12 @@ public function readLink(string $path): string public function removeBrokenLinksAt(string $path): void { collect($this->scandir($path)) - ->filter(function ($file) use ($path) { - return $this->isBrokenLink($path.'/'.$file); - }) - ->each(function ($file) use ($path) { - $this->unlink($path.'/'.$file); - }); + ->filter(function ($file) use ($path) { + return $this->isBrokenLink($path.'/'.$file); + }) + ->each(function ($file) use ($path) { + $this->unlink($path.'/'.$file); + }); } /** @@ -265,9 +265,9 @@ public function isBrokenLink(string $path): bool public function scandir(string $path): array { return collect(scandir($path)) - ->reject(function ($file) { - return in_array($file, ['.', '..']); - })->values()->all(); + ->reject(function ($file) { + return in_array($file, ['.', '..']); + })->values()->all(); } /** diff --git a/cli/Valet/Nginx.php b/cli/Valet/Nginx.php index 33f7b89de..9c383b645 100644 --- a/cli/Valet/Nginx.php +++ b/cli/Valet/Nginx.php @@ -10,7 +10,7 @@ class Nginx const NGINX_CONF = BREW_PREFIX.'/etc/nginx/nginx.conf'; public function __construct(public Brew $brew, public CommandLine $cli, public Filesystem $files, - public Configuration $configuration, public Site $site) + public Configuration $configuration, public Site $site) { } diff --git a/cli/Valet/Site.php b/cli/Valet/Site.php index 1136c9278..28bcb08e1 100644 --- a/cli/Valet/Site.php +++ b/cli/Valet/Site.php @@ -132,32 +132,32 @@ public function proxies(): Collection } $proxies = collect($this->files->scandir($dir)) - ->filter(function ($site, $key) use ($tld) { - // keep sites that match our TLD - return ends_with($site, '.'.$tld); - })->map(function ($site, $key) use ($tld) { - // remove the TLD suffix for consistency - return str_replace('.'.$tld, '', $site); - })->reject(function ($site, $key) use ($links) { - return $links->has($site); - })->mapWithKeys(function ($site) { - $host = $this->getProxyHostForSite($site) ?: '(other)'; - - return [$site => $host]; - })->reject(function ($host, $site) { - // If proxy host is null, it may be just a normal SSL stub, or something else; either way we exclude it from the list - return $host === '(other)'; - })->map(function ($host, $site) use ($certs, $tld) { - $secured = $certs->has($site); - $url = ($secured ? 'https' : 'http').'://'.$site.'.'.$tld; - - return [ - 'site' => $site, - 'secured' => $secured ? ' X' : '', - 'url' => $url, - 'path' => $host, - ]; - }); + ->filter(function ($site, $key) use ($tld) { + // keep sites that match our TLD + return ends_with($site, '.'.$tld); + })->map(function ($site, $key) use ($tld) { + // remove the TLD suffix for consistency + return str_replace('.'.$tld, '', $site); + })->reject(function ($site, $key) use ($links) { + return $links->has($site); + })->mapWithKeys(function ($site) { + $host = $this->getProxyHostForSite($site) ?: '(other)'; + + return [$site => $host]; + })->reject(function ($host, $site) { + // If proxy host is null, it may be just a normal SSL stub, or something else; either way we exclude it from the list + return $host === '(other)'; + })->map(function ($host, $site) use ($certs, $tld) { + $secured = $certs->has($site); + $url = ($secured ? 'https' : 'http').'://'.$site.'.'.$tld; + + return [ + 'site' => $site, + 'secured' => $secured ? ' X' : '', + 'url' => $url, + 'path' => $host, + ]; + }); return $proxies; } @@ -428,11 +428,11 @@ public function replaceOldLoopbackWithNew(string $siteConf, string $old, string public function secured(): array { return collect($this->files->scandir($this->certificatesPath())) - ->filter(function ($file) { - return ends_with($file, ['.key', '.csr', '.crt', '.conf']); - })->map(function ($file) { - return str_replace(['.key', '.csr', '.crt', '.conf'], '', $file); - })->unique()->values()->all(); + ->filter(function ($file) { + return ends_with($file, ['.key', '.csr', '.crt', '.conf']); + })->map(function ($file) { + return str_replace(['.key', '.csr', '.crt', '.conf'], '', $file); + })->unique()->values()->all(); } public function isSecured(string $site): bool diff --git a/tests/BrewTest.php b/tests/BrewTest.php index a54ab588e..16012bbca 100644 --- a/tests/BrewTest.php +++ b/tests/BrewTest.php @@ -35,13 +35,13 @@ public function test_installed_returns_true_when_given_formula_is_installed() { $cli = Mockery::mock(CommandLine::class); $cli->shouldReceive('runAsUser')->once()->with('brew info php@8.2 --json=v2') - ->andReturn('{"formulae":[{"name":"php@8.2","full_name":"php@8.2","aliases":[],"versioned_formulae":[],"versions":{"stable":"8.2.5"},"installed":[{"version":"8.2.5"}]}]}'); + ->andReturn('{"formulae":[{"name":"php@8.2","full_name":"php@8.2","aliases":[],"versioned_formulae":[],"versions":{"stable":"8.2.5"},"installed":[{"version":"8.2.5"}]}]}'); swap(CommandLine::class, $cli); $this->assertTrue(resolve(Brew::class)->installed('php@8.2')); $cli = Mockery::mock(CommandLine::class); $cli->shouldReceive('runAsUser')->once()->with('brew info php --json=v2') - ->andReturn('{"formulae":[{"name":"php","full_name":"php","aliases":["php@8.0"],"versioned_formulae":[],"versions":{"stable":"8.0.0"},"installed":[{"version":"8.0.0"}]}]}'); + ->andReturn('{"formulae":[{"name":"php","full_name":"php","aliases":["php@8.0"],"versioned_formulae":[],"versions":{"stable":"8.0.0"},"installed":[{"version":"8.0.0"}]}]}'); swap(CommandLine::class, $cli); $this->assertTrue(resolve(Brew::class)->installed('php')); } From bfbdb075eb19830d2ea88b9e1f40abb548e459b1 Mon Sep 17 00:00:00 2001 From: mattstauffer Date: Wed, 26 Apr 2023 13:35:44 +0000 Subject: [PATCH 06/68] Fix code styling --- cli/Valet/Configuration.php | 1 + 1 file changed, 1 insertion(+) diff --git a/cli/Valet/Configuration.php b/cli/Valet/Configuration.php index b62d9e63a..1180897b9 100644 --- a/cli/Valet/Configuration.php +++ b/cli/Valet/Configuration.php @@ -155,6 +155,7 @@ public function read(): array if ($this->files->exists($this->path())) { return json_decode($this->files->get($this->path()), true, 512, JSON_THROW_ON_ERROR); } + return []; } From 2497181106b4a74c4416f6010193c94f043212a2 Mon Sep 17 00:00:00 2001 From: Matt Stauffer Date: Wed, 26 Apr 2023 09:36:37 -0400 Subject: [PATCH 07/68] Change flow --- cli/Valet/Configuration.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/cli/Valet/Configuration.php b/cli/Valet/Configuration.php index b62d9e63a..b4b182434 100644 --- a/cli/Valet/Configuration.php +++ b/cli/Valet/Configuration.php @@ -152,10 +152,11 @@ public function prune(): void */ public function read(): array { - if ($this->files->exists($this->path())) { - return json_decode($this->files->get($this->path()), true, 512, JSON_THROW_ON_ERROR); + if (! $this->files->exists($this->path())) { + return []; } - return []; + + return json_decode($this->files->get($this->path()), true, 512, JSON_THROW_ON_ERROR); } /** From 97411ee1d0dcf360275dddfda244a588c76caac8 Mon Sep 17 00:00:00 2001 From: Dries Vints Date: Wed, 26 Apr 2023 17:40:58 +0200 Subject: [PATCH 08/68] Update app.php --- cli/app.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/app.php b/cli/app.php index 499e6259f..fde8dd19f 100644 --- a/cli/app.php +++ b/cli/app.php @@ -32,7 +32,7 @@ */ Container::setInstance(new Container); -$version = '4.0.1'; +$version = '4.0.2'; $app = new Application('Laravel Valet', $version); From a2b4fef751595603a68db86c243c01eb7163b685 Mon Sep 17 00:00:00 2001 From: driesvints Date: Wed, 26 Apr 2023 15:41:45 +0000 Subject: [PATCH 09/68] Update CHANGELOG --- CHANGELOG.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 54945d329..65b6bcb4b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,11 @@ # Release Notes -## [Unreleased](https://github.com/laravel/valet/compare/v4.0.1...master) +## [Unreleased](https://github.com/laravel/valet/compare/v4.0.2...master) + +## [v4.0.2](https://github.com/laravel/valet/compare/v4.0.1...v4.0.2) - 2023-04-26 + +- Fix ngrok.io proxy/forwarding detection by @drbyte in https://github.com/laravel/valet/pull/1404 +- Fix read non existing config file by @mischabraam in https://github.com/laravel/valet/pull/1398 ## [v4.0.1](https://github.com/laravel/valet/compare/v4.0.0...v4.0.1) - 2023-03-27 From 9c974cd39104369af01dfb197bb255b8a86b21e8 Mon Sep 17 00:00:00 2001 From: Dries Vints Date: Thu, 27 Apr 2023 09:45:38 +0200 Subject: [PATCH 10/68] Create RELEASE.md --- RELEASE.md | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 RELEASE.md diff --git a/RELEASE.md b/RELEASE.md new file mode 100644 index 000000000..b7dd92959 --- /dev/null +++ b/RELEASE.md @@ -0,0 +1,4 @@ +# Release Instructions + +1. Update the `$version` variable in [`app.php`](./cli/app.php) and commit it +2. Create a new GitHub release for this version with the release notes From b64f68675873b6fe831374f1032be60b25fdb8bf Mon Sep 17 00:00:00 2001 From: Chris Sorrentino Date: Wed, 3 May 2023 10:56:02 -0400 Subject: [PATCH 11/68] Add driver for Radicle --- .../Drivers/Specific/RadicleValetDriver.php | 73 +++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 cli/Valet/Drivers/Specific/RadicleValetDriver.php diff --git a/cli/Valet/Drivers/Specific/RadicleValetDriver.php b/cli/Valet/Drivers/Specific/RadicleValetDriver.php new file mode 100644 index 000000000..2d4338cc0 --- /dev/null +++ b/cli/Valet/Drivers/Specific/RadicleValetDriver.php @@ -0,0 +1,73 @@ +isActualFile($staticFilePath)) { + return $staticFilePath; + } + return false; + } + + /** + * Get the fully resolved path to the application's front controller. + * + * @param string $sitePath + * @param string $siteName + * @param string $uri + * @return string + */ + public function frontControllerPath(string $sitePath, string $siteName, string $uri): string + { + $_SERVER['PHP_SELF'] = $uri; + if (strpos($uri, '/wp/') === 0) { + return is_dir($sitePath . '/public' . $uri) + ? $sitePath . '/public' . $this->forceTrailingSlash($uri) . '/index.php' + : $sitePath . '/public' . $uri; + } + return $sitePath . '/public/index.php'; + } + + /** + * Redirect to uri with trailing slash. + * + * @param string $uri + * @return string + */ + private function forceTrailingSlash(string $uri) + { + if (substr($uri, -1 * strlen('/wp/wp-admin')) == '/wp/wp-admin') { + header('Location: ' . $uri . '/'); + die; + } + return $uri; + } +} From 5e69eab56c70fe028dd2fcf733ee1366acbfdeda Mon Sep 17 00:00:00 2001 From: Chris Sorrentino Date: Wed, 3 May 2023 11:29:04 -0400 Subject: [PATCH 12/68] fix namespacing --- cli/Valet/Drivers/Specific/RadicleValetDriver.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/cli/Valet/Drivers/Specific/RadicleValetDriver.php b/cli/Valet/Drivers/Specific/RadicleValetDriver.php index 2d4338cc0..51ab94224 100644 --- a/cli/Valet/Drivers/Specific/RadicleValetDriver.php +++ b/cli/Valet/Drivers/Specific/RadicleValetDriver.php @@ -1,9 +1,10 @@ Date: Fri, 5 May 2023 19:05:18 +0000 Subject: [PATCH 13/68] Fix code styling --- .../Drivers/Specific/RadicleValetDriver.php | 37 +++++++------------ 1 file changed, 13 insertions(+), 24 deletions(-) diff --git a/cli/Valet/Drivers/Specific/RadicleValetDriver.php b/cli/Valet/Drivers/Specific/RadicleValetDriver.php index 51ab94224..c7b85d502 100644 --- a/cli/Valet/Drivers/Specific/RadicleValetDriver.php +++ b/cli/Valet/Drivers/Specific/RadicleValetDriver.php @@ -8,67 +8,56 @@ class RadicleValetDriver extends BasicValetDriver { /** * Determine if the driver serves the request. - * - * @param string $sitePath - * @param string $siteName - * @param string $uri - * @return bool */ public function serves(string $sitePath, string $siteName, string $uri): bool { - return file_exists($sitePath . '/public/content/mu-plugins/bedrock-autoloader.php') && - file_exists($sitePath . '/public/wp-config.php') && - file_exists($sitePath . '/bedrock/application.php'); + return file_exists($sitePath.'/public/content/mu-plugins/bedrock-autoloader.php') && + file_exists($sitePath.'/public/wp-config.php') && + file_exists($sitePath.'/bedrock/application.php'); } /** * Determine if the incoming request is for a static file. * - * @param string $sitePath - * @param string $siteName - * @param string $uri * @return string|false */ public function isStaticFile(string $sitePath, string $siteName, string $uri)/*: string|false */ { - $staticFilePath = $sitePath . '/public' . $uri; + $staticFilePath = $sitePath.'/public'.$uri; if ($this->isActualFile($staticFilePath)) { return $staticFilePath; } + return false; } /** * Get the fully resolved path to the application's front controller. - * - * @param string $sitePath - * @param string $siteName - * @param string $uri - * @return string */ public function frontControllerPath(string $sitePath, string $siteName, string $uri): string { $_SERVER['PHP_SELF'] = $uri; if (strpos($uri, '/wp/') === 0) { - return is_dir($sitePath . '/public' . $uri) - ? $sitePath . '/public' . $this->forceTrailingSlash($uri) . '/index.php' - : $sitePath . '/public' . $uri; + return is_dir($sitePath.'/public'.$uri) + ? $sitePath.'/public'.$this->forceTrailingSlash($uri).'/index.php' + : $sitePath.'/public'.$uri; } - return $sitePath . '/public/index.php'; + + return $sitePath.'/public/index.php'; } /** * Redirect to uri with trailing slash. * - * @param string $uri * @return string */ private function forceTrailingSlash(string $uri) { if (substr($uri, -1 * strlen('/wp/wp-admin')) == '/wp/wp-admin') { - header('Location: ' . $uri . '/'); - die; + header('Location: '.$uri.'/'); + exit; } + return $uri; } } From 0f95b0314587699f5d8a3f478922bae3f784a2d4 Mon Sep 17 00:00:00 2001 From: Matt Stauffer Date: Fri, 5 May 2023 15:05:48 -0400 Subject: [PATCH 14/68] Fix Radicle code style with Pint --- .../Drivers/Specific/RadicleValetDriver.php | 37 +++++++------------ 1 file changed, 13 insertions(+), 24 deletions(-) diff --git a/cli/Valet/Drivers/Specific/RadicleValetDriver.php b/cli/Valet/Drivers/Specific/RadicleValetDriver.php index 51ab94224..c7b85d502 100644 --- a/cli/Valet/Drivers/Specific/RadicleValetDriver.php +++ b/cli/Valet/Drivers/Specific/RadicleValetDriver.php @@ -8,67 +8,56 @@ class RadicleValetDriver extends BasicValetDriver { /** * Determine if the driver serves the request. - * - * @param string $sitePath - * @param string $siteName - * @param string $uri - * @return bool */ public function serves(string $sitePath, string $siteName, string $uri): bool { - return file_exists($sitePath . '/public/content/mu-plugins/bedrock-autoloader.php') && - file_exists($sitePath . '/public/wp-config.php') && - file_exists($sitePath . '/bedrock/application.php'); + return file_exists($sitePath.'/public/content/mu-plugins/bedrock-autoloader.php') && + file_exists($sitePath.'/public/wp-config.php') && + file_exists($sitePath.'/bedrock/application.php'); } /** * Determine if the incoming request is for a static file. * - * @param string $sitePath - * @param string $siteName - * @param string $uri * @return string|false */ public function isStaticFile(string $sitePath, string $siteName, string $uri)/*: string|false */ { - $staticFilePath = $sitePath . '/public' . $uri; + $staticFilePath = $sitePath.'/public'.$uri; if ($this->isActualFile($staticFilePath)) { return $staticFilePath; } + return false; } /** * Get the fully resolved path to the application's front controller. - * - * @param string $sitePath - * @param string $siteName - * @param string $uri - * @return string */ public function frontControllerPath(string $sitePath, string $siteName, string $uri): string { $_SERVER['PHP_SELF'] = $uri; if (strpos($uri, '/wp/') === 0) { - return is_dir($sitePath . '/public' . $uri) - ? $sitePath . '/public' . $this->forceTrailingSlash($uri) . '/index.php' - : $sitePath . '/public' . $uri; + return is_dir($sitePath.'/public'.$uri) + ? $sitePath.'/public'.$this->forceTrailingSlash($uri).'/index.php' + : $sitePath.'/public'.$uri; } - return $sitePath . '/public/index.php'; + + return $sitePath.'/public/index.php'; } /** * Redirect to uri with trailing slash. * - * @param string $uri * @return string */ private function forceTrailingSlash(string $uri) { if (substr($uri, -1 * strlen('/wp/wp-admin')) == '/wp/wp-admin') { - header('Location: ' . $uri . '/'); - die; + header('Location: '.$uri.'/'); + exit; } + return $uri; } } From 615d61dc8eff594f599002a75ed22f692ea443f2 Mon Sep 17 00:00:00 2001 From: Chris Brown Date: Tue, 2 May 2023 22:13:47 -0400 Subject: [PATCH 15/68] Install older PHP versions via alternate tap Fixes #1407 Homebrew's support policy now aggressively disables older versions earlier than it did previously. That is why we tap the `shivammathur/php` repository. But since Homebrew also now "keeps" those old formulae but marks them as disabled, when Valet runs `brew install php@7.4` it fails because Homebrew just aborts due to its flags in the outdated formula. (They mark it as "disabled" and/or "keg_only :versioned_formula", but don't actually delete the formula from their repository.) To override that we must use `brew install shivammathur/php/php@7.4` internally. Therefore, we need to maintain a list of which PHP Versions we wish to specifically prefix with the `shivammathur/php` tap in order to bypass Homebrew's flags. **ANNUAL MAINTENANCE** 1. This PR adds the array of `LIMITED_PHP_VERSIONS` which we will have to update annually when new PHP versions are retired as others are released. 2. We should also annually update the `LATEST_PHP_VERSION` string. --- cli/Valet/Brew.php | 30 +++++++++++++++++++++++++++--- tests/BrewTest.php | 16 ++++++++++++++++ 2 files changed, 43 insertions(+), 3 deletions(-) diff --git a/cli/Valet/Brew.php b/cli/Valet/Brew.php index 2acf68b9f..4a0660569 100644 --- a/cli/Valet/Brew.php +++ b/cli/Valet/Brew.php @@ -8,6 +8,7 @@ class Brew { + // This is the array of PHP versions that Valet will attempt to install/configure when requested const SUPPORTED_PHP_VERSIONS = [ 'php', 'php@8.2', @@ -19,9 +20,22 @@ class Brew 'php@7.1', ]; - const BREW_DISABLE_AUTO_CLEANUP = 'HOMEBREW_NO_INSTALL_CLEANUP=1'; + // Update this LATEST and the following LIMITED array when PHP versions are released or retired + // We specify a numbered version here even though Homebrew links its generic 'php' alias to it + const LATEST_PHP_VERSION = 'php@8.2'; - const LATEST_PHP_VERSION = 'php@8.1'; + // These are the PHP versions that should be installed via the shivammathur/php tap because + // Homebrew officially no longer bottles them or they're marked disabled in their formula + // Cue: Homebrew reports "php@7.4 has been disabled because it is a versioned formula" + const LIMITED_PHP_VERSIONS = [ + 'php@8.0', + 'php@7.4', + 'php@7.3', + 'php@7.2', + 'php@7.1', + ]; + + const BREW_DISABLE_AUTO_CLEANUP = 'HOMEBREW_NO_INSTALL_CLEANUP=1'; public function __construct(public CommandLine $cli, public Filesystem $files) { @@ -72,6 +86,14 @@ public function supportedPhpVersions(): Collection return collect(static::SUPPORTED_PHP_VERSIONS); } + /** + * Get a list of disabled/limited PHP versions. + */ + public function limitedPhpVersions(): Collection + { + return collect(static::LIMITED_PHP_VERSIONS); + } + /** * Get a list of installed PHP formulae. */ @@ -135,7 +157,9 @@ public function installOrFail(string $formula, array $options = [], array $taps } output('['.$formula.'] is not installed, installing it now via Brew... 🍻'); - if ($formula !== 'php' && starts_with($formula, 'php') && preg_replace('/[^\d]/', '', $formula) < '73') { + + if ($this->limitedPhpVersions()->contains($formula)) { + $formula = 'shivammathur/php/' . $formula; warning('Note: older PHP versions may take 10+ minutes to compile from source. Please wait ...'); } diff --git a/tests/BrewTest.php b/tests/BrewTest.php index 16012bbca..f2cbee167 100644 --- a/tests/BrewTest.php +++ b/tests/BrewTest.php @@ -203,6 +203,22 @@ public function test_linked_php_throws_exception_if_unsupported_php_version_is_l resolve(Brew::class)->linkedPhp(); } + public function test_outdated_php_versions_use_the_alternate_tap() + { + $brewMock = Mockery::mock(Brew::class, [ + $cli = Mockery::mock(CommandLine::class), + Mockery::mock(Filesystem::class), + ])->makePartial(); + + $brewMock->shouldReceive('limitedPhpVersions')->andReturn(collect([ + 'php@7.0', + ])); + + $cli->shouldReceive('runAsUser')->once()->with(Brew::BREW_DISABLE_AUTO_CLEANUP.' brew install shivammathur/php/php@7.0', Mockery::type('Closure')); + + $brewMock->installOrFail('php@7.0'); + } + public function test_install_or_fail_will_install_brew_formulae() { $cli = Mockery::mock(CommandLine::class); From 0d3d537f507e456b143e64952b2d5761ee459659 Mon Sep 17 00:00:00 2001 From: Dries Vints Date: Tue, 9 May 2023 17:53:19 +0200 Subject: [PATCH 16/68] Update app.php --- cli/app.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/app.php b/cli/app.php index fde8dd19f..e2fad8e09 100644 --- a/cli/app.php +++ b/cli/app.php @@ -32,7 +32,7 @@ */ Container::setInstance(new Container); -$version = '4.0.2'; +$version = '4.1.0'; $app = new Application('Laravel Valet', $version); From a6f0c643dbbac51bcf2242281c9759cbe8c0a59a Mon Sep 17 00:00:00 2001 From: driesvints Date: Tue, 9 May 2023 15:54:07 +0000 Subject: [PATCH 17/68] Update CHANGELOG --- CHANGELOG.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 65b6bcb4b..4ceb26215 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,10 @@ # Release Notes -## [Unreleased](https://github.com/laravel/valet/compare/v4.0.2...master) +## [Unreleased](https://github.com/laravel/valet/compare/v4.1.0...master) + +## [v4.1.0](https://github.com/laravel/valet/compare/v4.0.2...v4.1.0) - 2023-05-09 + +- Add driver for Radicle by @csorrentino in https://github.com/laravel/valet/pull/1413 ## [v4.0.2](https://github.com/laravel/valet/compare/v4.0.1...v4.0.2) - 2023-04-26 From a4145d77b5f41777a96092f92b5eb1b56f138873 Mon Sep 17 00:00:00 2001 From: mattstauffer Date: Fri, 12 May 2023 02:23:35 +0000 Subject: [PATCH 18/68] Fix code styling --- cli/Valet/Brew.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/Valet/Brew.php b/cli/Valet/Brew.php index 4a0660569..d35b1c0ce 100644 --- a/cli/Valet/Brew.php +++ b/cli/Valet/Brew.php @@ -159,7 +159,7 @@ public function installOrFail(string $formula, array $options = [], array $taps output('['.$formula.'] is not installed, installing it now via Brew... 🍻'); if ($this->limitedPhpVersions()->contains($formula)) { - $formula = 'shivammathur/php/' . $formula; + $formula = 'shivammathur/php/'.$formula; warning('Note: older PHP versions may take 10+ minutes to compile from source. Please wait ...'); } From 55ceb3a7ad7c229e197f397035a7139069962a67 Mon Sep 17 00:00:00 2001 From: Matt Stauffer Date: Mon, 15 May 2023 12:26:47 -0400 Subject: [PATCH 19/68] Load specific drivers before custom drivers to allow for extension. Co-Authored-By: Chris Brown --- cli/Valet/Drivers/ValetDriver.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cli/Valet/Drivers/ValetDriver.php b/cli/Valet/Drivers/ValetDriver.php index f9eb5d7ea..7ce24987c 100644 --- a/cli/Valet/Drivers/ValetDriver.php +++ b/cli/Valet/Drivers/ValetDriver.php @@ -33,6 +33,9 @@ public static function assign(string $sitePath, string $siteName, string $uri): { $drivers = []; + // Must scan these so they're extensible by customSiteDrivers loaded next + $specificDrivers = static::specificDrivers(); + // Queue custom driver based on path if ($customSiteDriver = static::customSiteDriver($sitePath)) { $drivers[] = $customSiteDriver; @@ -43,7 +46,7 @@ public static function assign(string $sitePath, string $siteName, string $uri): // Queue Valet-shipped drivers $drivers[] = 'LaravelValetDriver'; - $drivers = array_merge($drivers, static::specificDrivers()); + $drivers = array_merge($drivers, $specificDrivers); $drivers[] = 'BasicWithPublicValetDriver'; $drivers[] = 'BasicValetDriver'; From 9ce0ca97b25eab48406fb37e2cbd60f06c5e19cd Mon Sep 17 00:00:00 2001 From: Matt Stauffer Date: Tue, 16 May 2023 08:23:41 -0400 Subject: [PATCH 20/68] Ensure base configuration is correct even if file already exists --- cli/Valet/Configuration.php | 22 ++++++++++++++++++++-- cli/app.php | 4 +--- tests/ConfigurationTest.php | 10 ++++++++++ 3 files changed, 31 insertions(+), 5 deletions(-) diff --git a/cli/Valet/Configuration.php b/cli/Valet/Configuration.php index b4b182434..d2cc8498d 100644 --- a/cli/Valet/Configuration.php +++ b/cli/Valet/Configuration.php @@ -2,6 +2,8 @@ namespace Valet; +use Exception; + class Configuration { public function __construct(public Filesystem $files) @@ -18,7 +20,7 @@ public function install(): void $this->createSitesDirectory(); $this->createLogDirectory(); $this->createCertificatesDirectory(); - $this->writeBaseConfiguration(); + $this->ensureBaseConfiguration(); $this->files->chown($this->path(), user()); } @@ -84,7 +86,23 @@ public function createCertificatesDirectory(): void } /** - * Write the base, initial configuration for Valet. + * Ensure the base initial configuration has been installed. + */ + public function ensureBaseConfiguration(): void + { + $this->writeBaseConfiguration(); + + if (empty($this->read()['tld'])) { + $this->updateKey('tld', 'test'); + } + + if (empty($this->read()['loopback'])) { + $this->updateKey('loopback', '127.0.0.1'); + } + } + + /** + * Write the base initial configuration for Valet. */ public function writeBaseConfiguration(): void { diff --git a/cli/app.php b/cli/app.php index e2fad8e09..3d1356db4 100644 --- a/cli/app.php +++ b/cli/app.php @@ -100,9 +100,7 @@ function (ConsoleCommandEvent $event) { /** * Upgrade helper: ensure the tld config exists and the loopback config exists. */ - if (empty(Configuration::read()['tld']) || empty(Configuration::read()['loopback'])) { - Configuration::writeBaseConfiguration(); - } + Configuration::ensureBaseConfiguration(); /** * Get or set the TLD currently being used by Valet. diff --git a/tests/ConfigurationTest.php b/tests/ConfigurationTest.php index 6af29ab51..187e3026b 100644 --- a/tests/ConfigurationTest.php +++ b/tests/ConfigurationTest.php @@ -132,4 +132,14 @@ public function test_trust_adds_the_sudoer_files() resolve(Brew::class)->createSudoersEntry(); resolve(Valet::class)->createSudoersEntry(); } + + public function test_ensure_configuration_exists_writes_tld_and_loopback_if_empty() + { + $config = Mockery::mock(Configuration::class.'[writeBaseConfiguration,read,updateKey]', [new Filesystem]); + $config->shouldReceive('writeBaseConfiguration')->once(); + $config->shouldReceive('read')->times(2)->andReturn([]); + $config->shouldReceive('updateKey')->with('tld', 'test'); + $config->shouldReceive('updateKey')->with('loopback', '127.0.0.1'); + $config->ensureBaseConfiguration(); + } } From 57d43bb289fd122fd94de0ba030778c12e5e5de3 Mon Sep 17 00:00:00 2001 From: Dries Vints Date: Tue, 16 May 2023 17:41:40 +0200 Subject: [PATCH 21/68] Update app.php --- cli/app.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/app.php b/cli/app.php index e2fad8e09..096d27866 100644 --- a/cli/app.php +++ b/cli/app.php @@ -32,7 +32,7 @@ */ Container::setInstance(new Container); -$version = '4.1.0'; +$version = '4.1.1'; $app = new Application('Laravel Valet', $version); From 3f8396dfaaee12c2d6b4a1c2869a3939e663b817 Mon Sep 17 00:00:00 2001 From: driesvints Date: Tue, 16 May 2023 15:42:58 +0000 Subject: [PATCH 22/68] Update CHANGELOG --- CHANGELOG.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4ceb26215..c1c00558b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,10 @@ # Release Notes -## [Unreleased](https://github.com/laravel/valet/compare/v4.1.0...master) +## [Unreleased](https://github.com/laravel/valet/compare/v4.1.1...master) + +## [v4.1.1](https://github.com/laravel/valet/compare/v4.1.0...v4.1.1) - 2023-05-16 + +- Install older PHP versions via alternate tap by @drbyte in https://github.com/laravel/valet/pull/1411 ## [v4.1.0](https://github.com/laravel/valet/compare/v4.0.2...v4.1.0) - 2023-05-09 From a28d958afd2f3459d7629d51fb5dde2178ba3d3c Mon Sep 17 00:00:00 2001 From: mattstauffer Date: Tue, 16 May 2023 19:27:36 +0000 Subject: [PATCH 23/68] Fix code styling --- cli/Valet/Configuration.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/cli/Valet/Configuration.php b/cli/Valet/Configuration.php index d2cc8498d..b7061a311 100644 --- a/cli/Valet/Configuration.php +++ b/cli/Valet/Configuration.php @@ -2,8 +2,6 @@ namespace Valet; -use Exception; - class Configuration { public function __construct(public Filesystem $files) From 3bb54ae5b0392fcf2b267f15480b46c7465712b6 Mon Sep 17 00:00:00 2001 From: Dries Vints Date: Tue, 30 May 2023 16:52:55 +0200 Subject: [PATCH 24/68] Update app.php --- cli/app.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/app.php b/cli/app.php index a2ac16280..5e66c10f3 100644 --- a/cli/app.php +++ b/cli/app.php @@ -32,7 +32,7 @@ */ Container::setInstance(new Container); -$version = '4.1.1'; +$version = '4.1.2'; $app = new Application('Laravel Valet', $version); From c7ace590baeb7130e3664b8e56dd1f68dbf9cc2d Mon Sep 17 00:00:00 2001 From: driesvints Date: Tue, 30 May 2023 14:53:31 +0000 Subject: [PATCH 25/68] Update CHANGELOG --- CHANGELOG.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c1c00558b..2a169c458 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,11 @@ # Release Notes -## [Unreleased](https://github.com/laravel/valet/compare/v4.1.1...master) +## [Unreleased](https://github.com/laravel/valet/compare/v4.1.2...master) + +## [v4.1.2](https://github.com/laravel/valet/compare/v4.1.1...v4.1.2) - 2023-05-30 + +- Load specific drivers before custom drivers to allow for extension. by @mattstauffer in https://github.com/laravel/valet/pull/1414 +- Ensure base configuration is correct even if file already exists by @mattstauffer in https://github.com/laravel/valet/pull/1415 ## [v4.1.1](https://github.com/laravel/valet/compare/v4.1.0...v4.1.1) - 2023-05-16 From 269d157b0abe24ab2c2716a030d7ffd769392cbd Mon Sep 17 00:00:00 2001 From: Chris Brown Date: Tue, 20 Jun 2023 16:30:04 -0400 Subject: [PATCH 26/68] Add "valet stop dnsmasq" option Fixes #1419 Adds: - `valet stop dnsmasq` - `valet stop all` (which includes php, nginx, dnsmasq) - When `valet stop` is called without a service name, a message indicates that dnsmasq can also be stopped via `valet stop dnsmasq` - Aside: phpfpm now also displays a message when stopping; previously it was silent. --- cli/Valet/DnsMasq.php | 8 ++++++++ cli/Valet/PhpFpm.php | 2 ++ cli/app.php | 14 ++++++++++++-- tests/CliTest.php | 17 ++++++++++++++++- 4 files changed, 38 insertions(+), 3 deletions(-) diff --git a/cli/Valet/DnsMasq.php b/cli/Valet/DnsMasq.php index 280682439..29d9ba736 100644 --- a/cli/Valet/DnsMasq.php +++ b/cli/Valet/DnsMasq.php @@ -47,6 +47,14 @@ public function uninstall(): void $this->files->unlink($this->resolverPath.'/'.$tld); } + /** + * Stop the dnsmasq service. + */ + public function stop(): void + { + $this->brew->stopService(['dnsmasq']); + } + /** * Tell Homebrew to restart dnsmasq. */ diff --git a/cli/Valet/PhpFpm.php b/cli/Valet/PhpFpm.php index e56cea13f..39d555851 100644 --- a/cli/Valet/PhpFpm.php +++ b/cli/Valet/PhpFpm.php @@ -112,6 +112,7 @@ public function restart(?string $phpVersion = null): void */ public function stop(): void { + info('Stopping phpfpm...'); call_user_func_array( [$this->brew, 'stopService'], Brew::SUPPORTED_PHP_VERSIONS @@ -138,6 +139,7 @@ public function fpmConfigPath(?string $phpVersion = null): string */ public function stopRunning(): void { + info('Stopping phpfpm...'); $this->brew->stopService( $this->brew->getAllRunningServices() ->filter(function ($service) { diff --git a/cli/app.php b/cli/app.php index 5e66c10f3..042750a5a 100644 --- a/cli/app.php +++ b/cli/app.php @@ -506,7 +506,13 @@ function (ConsoleCommandEvent $event) { PhpFpm::stopRunning(); Nginx::stop(); - return info('Valet services have been stopped.'); + return info('Valet core services have been stopped. To also stop dnsmasq, run: valet stop dnsmasq'); + case 'all': + PhpFpm::stopRunning(); + Nginx::stop(); + Dnsmasq::stop(); + + return info('All Valet services have been stopped.'); case 'nginx': Nginx::stop(); @@ -515,10 +521,14 @@ function (ConsoleCommandEvent $event) { PhpFpm::stopRunning(); return info('PHP has been stopped.'); + case 'dnsmasq': + Dnsmasq::stop(); + + return info('dnsmasq has been stopped.'); } return warning(sprintf('Invalid valet service name [%s]', $service)); - })->descriptions('Stop the Valet services'); + })->descriptions('Stop the core Valet services, or all services by specifying "all".'); /** * Uninstall Valet entirely. Requires --force to actually remove; otherwise manual instructions are displayed. diff --git a/tests/CliTest.php b/tests/CliTest.php index b2c6fdd76..cdc7e9a20 100644 --- a/tests/CliTest.php +++ b/tests/CliTest.php @@ -759,7 +759,7 @@ public function test_stop_command() $tester->run(['command' => 'stop']); $tester->assertCommandIsSuccessful(); - $this->assertStringContainsString('Valet services have been stopped.', $tester->getDisplay()); + $this->assertStringContainsString('Valet core services have been stopped.', $tester->getDisplay()); } public function test_stop_command_stops_nginx() @@ -792,6 +792,21 @@ public function test_stop_command_stops_php() $this->assertStringContainsString('PHP has been stopped', $tester->getDisplay()); } + public function test_stop_all_command_stops_dnsmasq() + { + [$app, $tester] = $this->appAndTester(); + + $phpfpm = Mockery::mock(DnsMasq::class); + $phpfpm->shouldReceive('stop'); + + swap(DnsMasq::class, $phpfpm); + + $tester->run(['command' => 'stop', 'service' => 'dnsmasq']); + $tester->assertCommandIsSuccessful(); + + $this->assertStringContainsString('dnsmasq has been stopped', $tester->getDisplay()); + } + public function test_stop_command_handles_bad_services() { [$app, $tester] = $this->appAndTester(); From b5103d15bbc43b11bce8268cc6fc9f0f775a12bd Mon Sep 17 00:00:00 2001 From: datashaman Date: Fri, 21 Jul 2023 05:30:32 +0200 Subject: [PATCH 27/68] Add quotes around $PHP (#1431) If the PHP executable path has a space in it, it breaks valet. For example, when using the new Laravel Herd which stores its config and binaries under `~/Library/Application Support/Herd/...` --- valet | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/valet b/valet index fb68db5a8..7eb7185d4 100755 --- a/valet +++ b/valet @@ -23,21 +23,21 @@ fi # Get a command-line executable we can use for php that's 8+; if this # is the inside loop (Valet runs itself 2x in some settings), skip # checking and pulling again by reading the exported env var -if [[ $PHP_EXECUTABLE = "" ]] +if [[ "$PHP_EXECUTABLE" = "" ]] then - PHP=$(php $DIR/find-usable-php.php) + PHP="$(php $DIR/find-usable-php.php)" # Validate output before running it on the CLI - if [[ ! -f $PHP ]]; then + if [[ ! -f "$PHP" ]]; then echo "Error finding executable PHP. Quitting for safety." echo "Provided output from find-usable-php.php:" echo $PHP exit fi - export PHP_EXECUTABLE=$PHP + export PHP_EXECUTABLE="$PHP" else - PHP=$PHP_EXECUTABLE + PHP="$PHP_EXECUTABLE" fi # If the command is the "share" command we will need to resolve out any @@ -81,7 +81,7 @@ then fi done - TLD=$($PHP "$DIR/cli/valet.php" tld) + TLD=$("$PHP" "$DIR/cli/valet.php" tld) # Decide the correct PORT: uses 60 for secure, else 80 if grep --quiet --no-messages 443 ~/.config/valet/Nginx/$HOST* @@ -124,7 +124,7 @@ then fi done - TLD=$($PHP "$DIR/cli/valet.php" tld) + TLD=$("$PHP" "$DIR/cli/valet.php" tld) # Decide the correct PORT: uses 443 for secure, else 80 if grep --quiet --no-messages 443 ~/.config/valet/Nginx/$HOST* @@ -182,5 +182,5 @@ else exit fi - $PHP "$DIR/cli/valet.php" "$@" + "$PHP" "$DIR/cli/valet.php" "$@" fi From c1ef3004692d908478891572572d0740570bbdca Mon Sep 17 00:00:00 2001 From: driesvints Date: Fri, 21 Jul 2023 03:30:59 +0000 Subject: [PATCH 28/68] Fix code styling --- cli/Valet/Brew.php | 2 +- cli/Valet/Expose.php | 2 +- cli/Valet/Filesystem.php | 10 +++++----- cli/Valet/Ngrok.php | 2 +- cli/Valet/PhpFpm.php | 8 ++++---- cli/Valet/Site.php | 22 +++++++++++----------- cli/includes/helpers.php | 2 +- tests/PhpFpmTest.php | 2 +- tests/SiteTest.php | 2 +- 9 files changed, 26 insertions(+), 26 deletions(-) diff --git a/cli/Valet/Brew.php b/cli/Valet/Brew.php index d35b1c0ce..d7e510955 100644 --- a/cli/Valet/Brew.php +++ b/cli/Valet/Brew.php @@ -291,7 +291,7 @@ function ($version) use ($resolvedPhpVersion) { * * @param string|null $phpVersion For example, "php@8.1" */ - public function getPhpExecutablePath(?string $phpVersion = null): string + public function getPhpExecutablePath(string $phpVersion = null): string { if (! $phpVersion) { return BREW_PREFIX.'/bin/php'; diff --git a/cli/Valet/Expose.php b/cli/Valet/Expose.php index abb1428c0..7f9651c48 100644 --- a/cli/Valet/Expose.php +++ b/cli/Valet/Expose.php @@ -11,7 +11,7 @@ public function __construct(public Composer $composer, public CommandLine $cli) { } - public function currentTunnelUrl(?string $domain = null): ?string + public function currentTunnelUrl(string $domain = null): ?string { $endpoint = 'http://127.0.0.1:4040/api/tunnels'; diff --git a/cli/Valet/Filesystem.php b/cli/Valet/Filesystem.php index 3b16d7f94..eaeb1232c 100644 --- a/cli/Valet/Filesystem.php +++ b/cli/Valet/Filesystem.php @@ -19,7 +19,7 @@ public function isDir(string $path): bool /** * Create a directory. */ - public function mkdir(string $path, ?string $owner = null, int $mode = 0755): void + public function mkdir(string $path, string $owner = null, int $mode = 0755): void { mkdir($path, $mode, true); @@ -31,7 +31,7 @@ public function mkdir(string $path, ?string $owner = null, int $mode = 0755): vo /** * Ensure that the given directory exists. */ - public function ensureDirExists(string $path, ?string $owner = null, int $mode = 0755): void + public function ensureDirExists(string $path, string $owner = null, int $mode = 0755): void { if (! $this->isDir($path)) { $this->mkdir($path, $owner, $mode); @@ -49,7 +49,7 @@ public function mkdirAsUser(string $path, int $mode = 0755): void /** * Touch the given path. */ - public function touch(string $path, ?string $owner = null): string + public function touch(string $path, string $owner = null): string { touch($path); @@ -87,7 +87,7 @@ public function get(string $path): string /** * Write to the given file. */ - public function put(string $path, string $contents, ?string $owner = null): void + public function put(string $path, string $contents, string $owner = null): void { file_put_contents($path, $contents); @@ -107,7 +107,7 @@ public function putAsUser(string $path, ?string $contents): void /** * Append the contents to the given file. */ - public function append(string $path, string $contents, ?string $owner = null): void + public function append(string $path, string $contents, string $owner = null): void { file_put_contents($path, $contents, FILE_APPEND); diff --git a/cli/Valet/Ngrok.php b/cli/Valet/Ngrok.php index c7c0d11d4..222806677 100644 --- a/cli/Valet/Ngrok.php +++ b/cli/Valet/Ngrok.php @@ -20,7 +20,7 @@ public function __construct(public CommandLine $cli, public Brew $brew) /** * Get the current tunnel URL from the Ngrok API. */ - public function currentTunnelUrl(?string $domain = null): string + public function currentTunnelUrl(string $domain = null): string { // wait a second for ngrok to start before attempting to find available tunnels sleep(1); diff --git a/cli/Valet/PhpFpm.php b/cli/Valet/PhpFpm.php index e56cea13f..0f2d8f421 100644 --- a/cli/Valet/PhpFpm.php +++ b/cli/Valet/PhpFpm.php @@ -102,7 +102,7 @@ public function createConfigurationFiles(string $phpVersion): void /** * Restart the PHP FPM process (if one specified) or processes (if none specified). */ - public function restart(?string $phpVersion = null): void + public function restart(string $phpVersion = null): void { $this->brew->restartService($phpVersion ?: $this->utilizedPhpVersions()); } @@ -121,7 +121,7 @@ public function stop(): void /** * Get the path to the FPM configuration file for the current PHP version. */ - public function fpmConfigPath(?string $phpVersion = null): string + public function fpmConfigPath(string $phpVersion = null): string { if (! $phpVersion) { $phpVersion = $this->brew->linkedPhp(); @@ -150,7 +150,7 @@ public function stopRunning(): void /** * Stop a given PHP version, if that specific version isn't being used globally or by any sites. */ - public function stopIfUnused(?string $phpVersion = null): void + public function stopIfUnused(string $phpVersion = null): void { if (! $phpVersion) { return; @@ -303,7 +303,7 @@ public function validateRequestedVersion(string $version): string /** * Get FPM sock file name for a given PHP version. */ - public static function fpmSockName(?string $phpVersion = null): string + public static function fpmSockName(string $phpVersion = null): string { $versionInteger = preg_replace('~[^\d]~', '', $phpVersion); diff --git a/cli/Valet/Site.php b/cli/Valet/Site.php index 28bcb08e1..f17825109 100644 --- a/cli/Valet/Site.php +++ b/cli/Valet/Site.php @@ -207,7 +207,7 @@ public function getProxyHostForSite(string $site, string $configContents = null) /** * Get the contents of the configuration for the given site. */ - public function getSiteConfigFileContents(string $site, ?string $suffix = null): ?string + public function getSiteConfigFileContents(string $site, string $suffix = null): ?string { $config = $this->config->read(); $suffix = $suffix ?: '.'.$config['tld']; @@ -219,7 +219,7 @@ public function getSiteConfigFileContents(string $site, ?string $suffix = null): /** * Get all certificates from config folder. */ - public function getCertificates(?string $path = null): Collection + public function getCertificates(string $path = null): Collection { $path = $path ?: $this->certificatesPath(); @@ -283,7 +283,7 @@ public function getSites(string $path, Collection $certs): Collection /** * Unlink the given symbolic link. */ - public function unlink(?string $name = null): string + public function unlink(string $name = null): string { $name = $this->getSiteLinkName($name); @@ -452,7 +452,7 @@ public function isSecured(string $site): bool * * @see https://github.com/cabforum/servercert/blob/main/docs/BR.md */ - public function secure(string $url, ?string $siteConf = null, int $certificateExpireInDays = 396, int $caExpireInYears = 20): void + public function secure(string $url, string $siteConf = null, int $certificateExpireInDays = 396, int $caExpireInYears = 20): void { // Extract in order to later preserve custom PHP version config when securing $phpVersion = $this->customPhpVersion($url); @@ -628,7 +628,7 @@ public function buildCertificateConf(string $path, string $url): void /** * Build the TLS secured Nginx server for the given URL. */ - public function buildSecureNginxServer(string $url, ?string $siteConf = null): string + public function buildSecureNginxServer(string $url, string $siteConf = null): string { if ($siteConf === null) { $siteConf = $this->replaceOldLoopbackWithNew( @@ -937,7 +937,7 @@ public function plistPath(): string /** * Get the path to Nginx site configuration files. */ - public function nginxPath(?string $additionalPath = null): string + public function nginxPath(string $additionalPath = null): string { return $this->valetHomePath().'/Nginx'.($additionalPath ? '/'.$additionalPath : ''); } @@ -945,7 +945,7 @@ public function nginxPath(?string $additionalPath = null): string /** * Get the path to the linked Valet sites. */ - public function sitesPath(?string $link = null): string + public function sitesPath(string $link = null): string { return $this->valetHomePath().'/Sites'.($link ? '/'.$link : ''); } @@ -953,7 +953,7 @@ public function sitesPath(?string $link = null): string /** * Get the path to the Valet CA certificates. */ - public function caPath(?string $caFile = null): string + public function caPath(string $caFile = null): string { return $this->valetHomePath().'/CA'.($caFile ? '/'.$caFile : ''); } @@ -961,7 +961,7 @@ public function caPath(?string $caFile = null): string /** * Get the path to the Valet TLS certificates. */ - public function certificatesPath(?string $url = null, ?string $extension = null): string + public function certificatesPath(string $url = null, string $extension = null): string { $url = $url ? '/'.$url : ''; $extension = $extension ? '.'.$extension : ''; @@ -1045,7 +1045,7 @@ public function replaceSockFile(string $siteConf, string $phpVersion): string /** * Get configuration items defined in .valetrc for a site. */ - public function valetRc(string $siteName, ?string $cwd = null): array + public function valetRc(string $siteName, string $cwd = null): array { if ($cwd) { $path = $cwd.'/.valetrc'; @@ -1071,7 +1071,7 @@ public function valetRc(string $siteName, ?string $cwd = null): array /** * Get PHP version from .valetrc or .valetphprc for a site. */ - public function phpRcVersion(string $siteName, ?string $cwd = null): ?string + public function phpRcVersion(string $siteName, string $cwd = null): ?string { if ($cwd) { $oldPath = $cwd.'/.valetphprc'; diff --git a/cli/includes/helpers.php b/cli/includes/helpers.php index f9d0ce89e..475594f05 100644 --- a/cli/includes/helpers.php +++ b/cli/includes/helpers.php @@ -32,7 +32,7 @@ /** * Set or get a global console writer. */ -function writer(?OutputInterface $writer = null): OutputInterface|\NullWriter|null +function writer(OutputInterface $writer = null): OutputInterface|\NullWriter|null { $container = Container::getInstance(); diff --git a/tests/PhpFpmTest.php b/tests/PhpFpmTest.php index f8723d0c0..eaea2bf29 100644 --- a/tests/PhpFpmTest.php +++ b/tests/PhpFpmTest.php @@ -448,7 +448,7 @@ public function test_isolate_will_throw_if_site_is_not_parked_or_linked() class StubForUpdatingFpmConfigFiles extends PhpFpm { - public function fpmConfigPath(?string $phpVersion = null): string + public function fpmConfigPath(string $phpVersion = null): string { return __DIR__.'/output/fpm.conf'; } diff --git a/tests/SiteTest.php b/tests/SiteTest.php index ffa80c78c..52b9e7d44 100644 --- a/tests/SiteTest.php +++ b/tests/SiteTest.php @@ -1082,7 +1082,7 @@ public function assertCertificateExistsWithCounterValue($urlWithTld, $counter) class StubForRemovingLinks extends Site { - public function sitesPath(?string $additionalPath = null): string + public function sitesPath(string $additionalPath = null): string { return __DIR__.'/output'.($additionalPath ? '/'.$additionalPath : ''); } From 31017e611a36f0ab124d87c1487d4e71e5f5fa5e Mon Sep 17 00:00:00 2001 From: Dries Vints Date: Fri, 21 Jul 2023 05:31:01 +0200 Subject: [PATCH 29/68] Update app.php --- cli/app.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/app.php b/cli/app.php index 5e66c10f3..be733304d 100644 --- a/cli/app.php +++ b/cli/app.php @@ -32,7 +32,7 @@ */ Container::setInstance(new Container); -$version = '4.1.2'; +$version = '4.1.3'; $app = new Application('Laravel Valet', $version); From 4007d256fd4c3889f0e51d2a6b730be1da419313 Mon Sep 17 00:00:00 2001 From: driesvints Date: Fri, 21 Jul 2023 03:31:45 +0000 Subject: [PATCH 30/68] Update CHANGELOG --- CHANGELOG.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2a169c458..1cf465c85 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,10 @@ # Release Notes -## [Unreleased](https://github.com/laravel/valet/compare/v4.1.2...master) +## [Unreleased](https://github.com/laravel/valet/compare/v4.1.3...master) + +## [v4.1.3](https://github.com/laravel/valet/compare/v4.1.2...v4.1.3) - 2023-07-21 + +- Add quotes around $PHP by [@datashaman](https://github.com/datashaman) in https://github.com/laravel/valet/pull/1431 ## [v4.1.2](https://github.com/laravel/valet/compare/v4.1.1...v4.1.2) - 2023-05-30 From 0a33373bb6b3ee7ac3c294535ea66ed02c902be4 Mon Sep 17 00:00:00 2001 From: Marcel Pociot Date: Wed, 26 Jul 2023 15:54:51 +0200 Subject: [PATCH 31/68] Only delete resolver when Herd is not installed --- cli/Valet/DnsMasq.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/cli/Valet/DnsMasq.php b/cli/Valet/DnsMasq.php index 280682439..0366daa2f 100644 --- a/cli/Valet/DnsMasq.php +++ b/cli/Valet/DnsMasq.php @@ -43,8 +43,13 @@ public function uninstall(): void $this->brew->stopService('dnsmasq'); $this->brew->uninstallFormula('dnsmasq'); $this->cli->run('rm -rf '.BREW_PREFIX.'/etc/dnsmasq.d/dnsmasq-valet.conf'); - $tld = $this->configuration->read()['tld']; - $this->files->unlink($this->resolverPath.'/'.$tld); + + // As Laravel Herd uses the same DnsMasq resolver, we should only + // delete if, if Herd is not installed. + if (!$this->files->exists('/Applications/Herd.app')) { + $tld = $this->configuration->read()['tld']; + $this->files->unlink($this->resolverPath . '/' . $tld); + } } /** From 2320d15f7d6c49d0ad9f876a756973339dcd302a Mon Sep 17 00:00:00 2001 From: Matt Stauffer Date: Fri, 11 Aug 2023 09:03:30 -0400 Subject: [PATCH 32/68] Update cli/Valet/DnsMasq.php Co-authored-by: Mateus Junges --- cli/Valet/DnsMasq.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/Valet/DnsMasq.php b/cli/Valet/DnsMasq.php index 0366daa2f..ef3dc0498 100644 --- a/cli/Valet/DnsMasq.php +++ b/cli/Valet/DnsMasq.php @@ -45,7 +45,7 @@ public function uninstall(): void $this->cli->run('rm -rf '.BREW_PREFIX.'/etc/dnsmasq.d/dnsmasq-valet.conf'); // As Laravel Herd uses the same DnsMasq resolver, we should only - // delete if, if Herd is not installed. + // delete it if Herd is not installed. if (!$this->files->exists('/Applications/Herd.app')) { $tld = $this->configuration->read()['tld']; $this->files->unlink($this->resolverPath . '/' . $tld); From d4ee503ec774c54dfd06bf2eb49794c544fbe1b9 Mon Sep 17 00:00:00 2001 From: mattstauffer Date: Fri, 11 Aug 2023 13:04:11 +0000 Subject: [PATCH 33/68] Fix code styling --- cli/Valet/DnsMasq.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cli/Valet/DnsMasq.php b/cli/Valet/DnsMasq.php index ef3dc0498..1932d6c43 100644 --- a/cli/Valet/DnsMasq.php +++ b/cli/Valet/DnsMasq.php @@ -46,9 +46,9 @@ public function uninstall(): void // As Laravel Herd uses the same DnsMasq resolver, we should only // delete it if Herd is not installed. - if (!$this->files->exists('/Applications/Herd.app')) { + if (! $this->files->exists('/Applications/Herd.app')) { $tld = $this->configuration->read()['tld']; - $this->files->unlink($this->resolverPath . '/' . $tld); + $this->files->unlink($this->resolverPath.'/'.$tld); } } From 9042c28a00e6925cc732d9728081f9ea2d963e62 Mon Sep 17 00:00:00 2001 From: Matt Stauffer Date: Mon, 14 Aug 2023 15:05:12 -0400 Subject: [PATCH 34/68] Bump version --- cli/app.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/app.php b/cli/app.php index be733304d..3aa416b24 100644 --- a/cli/app.php +++ b/cli/app.php @@ -32,7 +32,7 @@ */ Container::setInstance(new Container); -$version = '4.1.3'; +$version = '4.1.4'; $app = new Application('Laravel Valet', $version); From 2af8aba0684ca67573d52b6041d8ea981066a6a0 Mon Sep 17 00:00:00 2001 From: mattstauffer Date: Mon, 14 Aug 2023 19:05:59 +0000 Subject: [PATCH 35/68] Update CHANGELOG --- CHANGELOG.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1cf465c85..bd8646ea2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,14 @@ # Release Notes -## [Unreleased](https://github.com/laravel/valet/compare/v4.1.3...master) +## [Unreleased](https://github.com/laravel/valet/compare/v4.1.4...master) + +## [v4.1.4](https://github.com/laravel/valet/compare/v4.1.3...v4.1.4) - 2023-08-14 + +### What's Changed + +- Only delete DNSMasq resolver when Herd is not installed by [@mpociot](https://github.com/mpociot) in https://github.com/laravel/valet/pull/1434 + +**Full Changelog**: https://github.com/laravel/valet/compare/v4.1.3...v4.1.4 ## [v4.1.3](https://github.com/laravel/valet/compare/v4.1.2...v4.1.3) - 2023-07-21 From bb36a3b43752bdd52d299609226556f783bdcf29 Mon Sep 17 00:00:00 2001 From: Robert Boes <2871897+RobertBoes@users.noreply.github.com> Date: Fri, 25 Aug 2023 10:56:06 +0200 Subject: [PATCH 36/68] Add support for proxying multiple domains at once --- cli/Valet/Site.php | 58 +++++++------ tests/CliTest.php | 17 ++++ tests/SiteTest.php | 201 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 250 insertions(+), 26 deletions(-) diff --git a/cli/Valet/Site.php b/cli/Valet/Site.php index f17825109..c2096f01a 100644 --- a/cli/Valet/Site.php +++ b/cli/Valet/Site.php @@ -768,31 +768,34 @@ public function proxyCreate(string $url, string $host, bool $secure = false): vo } $tld = $this->config->read()['tld']; - if (! ends_with($url, '.'.$tld)) { - $url .= '.'.$tld; - } - $siteConf = $this->replaceOldLoopbackWithNew( - $this->files->getStub($secure ? 'secure.proxy.valet.conf' : 'proxy.valet.conf'), - 'VALET_LOOPBACK', - $this->valetLoopback() - ); + foreach (explode(',', $url) as $proxyUrl) { + if (! ends_with($proxyUrl, '.'.$tld)) { + $proxyUrl .= '.'.$tld; + } - $siteConf = str_replace( - ['VALET_HOME_PATH', 'VALET_SERVER_PATH', 'VALET_STATIC_PREFIX', 'VALET_SITE', 'VALET_PROXY_HOST'], - [$this->valetHomePath(), VALET_SERVER_PATH, VALET_STATIC_PREFIX, $url, $host], - $siteConf - ); + $siteConf = $this->replaceOldLoopbackWithNew( + $this->files->getStub($secure ? 'secure.proxy.valet.conf' : 'proxy.valet.conf'), + 'VALET_LOOPBACK', + $this->valetLoopback() + ); - if ($secure) { - $this->secure($url, $siteConf); - } else { - $this->put($url, $siteConf); - } + $siteConf = str_replace( + ['VALET_HOME_PATH', 'VALET_SERVER_PATH', 'VALET_STATIC_PREFIX', 'VALET_SITE', 'VALET_PROXY_HOST'], + [$this->valetHomePath(), VALET_SERVER_PATH, VALET_STATIC_PREFIX, $proxyUrl, $host], + $siteConf + ); + + if ($secure) { + $this->secure($proxyUrl, $siteConf); + } else { + $this->put($proxyUrl, $siteConf); + } - $protocol = $secure ? 'https' : 'http'; + $protocol = $secure ? 'https' : 'http'; - info('Valet will now proxy ['.$protocol.'://'.$url.'] traffic to ['.$host.'].'); + info('Valet will now proxy ['.$protocol.'://'.$proxyUrl.'] traffic to ['.$host.'].'); + } } /** @@ -801,14 +804,17 @@ public function proxyCreate(string $url, string $host, bool $secure = false): vo public function proxyDelete(string $url): void { $tld = $this->config->read()['tld']; - if (! ends_with($url, '.'.$tld)) { - $url .= '.'.$tld; - } - $this->unsecure($url); - $this->files->unlink($this->nginxPath($url)); + foreach (explode(',', $url) as $proxyUrl) { + if (! ends_with($proxyUrl, '.'.$tld)) { + $proxyUrl .= '.'.$tld; + } - info('Valet will no longer proxy [https://'.$url.'].'); + $this->unsecure($proxyUrl); + $this->files->unlink($this->nginxPath($proxyUrl)); + + info('Valet will no longer proxy [https://'.$proxyUrl.'].'); + } } /** diff --git a/tests/CliTest.php b/tests/CliTest.php index b2c6fdd76..3ffe395b5 100644 --- a/tests/CliTest.php +++ b/tests/CliTest.php @@ -396,6 +396,23 @@ public function test_proxy_command() $tester->assertCommandIsSuccessful(); } + public function test_proxy_command_with_multiple_domains() + { + [$app, $tester] = $this->appAndTester(); + + $site = Mockery::mock(RealSite::class); + $site->shouldReceive('proxyCreate')->with('my-app,subdomain.my-app', 'http://127.0.0.1:8000', false)->once(); + + $nginx = Mockery::mock(Nginx::class); + $nginx->shouldReceive('restart')->once(); + + swap(Nginx::class, $nginx); + swap(RealSite::class, $site); + + $tester->run(['command' => 'proxy', 'domain' => 'my-app,subdomain.my-app', 'host' => 'http://127.0.0.1:8000']); + $tester->assertCommandIsSuccessful(); + } + public function test_unproxy_command() { [$app, $tester] = $this->appAndTester(); diff --git a/tests/SiteTest.php b/tests/SiteTest.php index 52b9e7d44..cefa4ce57 100644 --- a/tests/SiteTest.php +++ b/tests/SiteTest.php @@ -405,6 +405,49 @@ public function test_add_proxy() ], $site->proxies()->all()); } + public function test_add_multiple_proxies() + { + $config = Mockery::mock(Configuration::class); + $config->shouldReceive('read') + ->andReturn(['tld' => 'test', 'loopback' => VALET_LOOPBACK]); + + swap(Configuration::class, $config); + + swap(CommandLine::class, resolve(CommandLineFake::class)); + + /** @var FixturesSiteFake $site */ + $site = resolve(FixturesSiteFake::class); + + $site->useOutput(); + + $site->assertCertificateNotExists('my-new-proxy.com.test'); + $site->assertCertificateNotExists('my-other-new-proxy.com.test'); + $site->assertNginxNotExists('my-new-proxy.com.test'); + $site->assertNginxNotExists('my-other-new-proxy.com.test'); + + $site->proxyCreate('my-new-proxy.com,my-other-new-proxy.com', 'https://127.0.0.1:9443', true); + + $site->assertCertificateExistsWithCounterValue('my-new-proxy.com.test', 0); + $site->assertCertificateExistsWithCounterValue('my-other-new-proxy.com.test', 1); + $site->assertNginxExists('my-new-proxy.com.test'); + $site->assertNginxExists('my-other-new-proxy.com.test'); + + $this->assertEquals([ + 'my-new-proxy.com' => [ + 'site' => 'my-new-proxy.com', + 'secured' => ' X', + 'url' => 'https://my-new-proxy.com.test', + 'path' => 'https://127.0.0.1:9443', + ], + 'my-other-new-proxy.com' => [ + 'site' => 'my-other-new-proxy.com', + 'secured' => ' X', + 'url' => 'https://my-other-new-proxy.com.test', + 'path' => 'https://127.0.0.1:9443', + ], + ], $site->proxies()->all()); + } + public function test_add_non_secure_proxy() { $config = Mockery::mock(Configuration::class); @@ -438,6 +481,49 @@ public function test_add_non_secure_proxy() ], $site->proxies()->all()); } + public function test_add_multiple_non_secure_proxies() + { + $config = Mockery::mock(Configuration::class); + $config->shouldReceive('read') + ->andReturn(['tld' => 'test', 'loopback' => VALET_LOOPBACK]); + + swap(Configuration::class, $config); + + swap(CommandLine::class, resolve(CommandLineFake::class)); + + /** @var FixturesSiteFake $site */ + $site = resolve(FixturesSiteFake::class); + + $site->useOutput(); + + $site->assertCertificateNotExists('my-new-proxy.com.test'); + $site->assertCertificateNotExists('my-other-new-proxy.com.test'); + $site->assertNginxNotExists('my-new-proxy.com.test'); + $site->assertNginxNotExists('my-other-new-proxy.com.test'); + + $site->proxyCreate('my-new-proxy.com,my-other-new-proxy.com', 'http://127.0.0.1:9443', false); + + $site->assertCertificateNotExists('my-new-proxy.com.test'); + $site->assertCertificateNotExists('my-other-new-proxy.com.test'); + $site->assertNginxExists('my-new-proxy.com.test'); + $site->assertNginxExists('my-other-new-proxy.com.test'); + + $this->assertEquals([ + 'my-new-proxy.com' => [ + 'site' => 'my-new-proxy.com', + 'secured' => '', + 'url' => 'http://my-new-proxy.com.test', + 'path' => 'http://127.0.0.1:9443', + ], + 'my-other-new-proxy.com' => [ + 'site' => 'my-other-new-proxy.com', + 'secured' => '', + 'url' => 'http://my-other-new-proxy.com.test', + 'path' => 'http://127.0.0.1:9443', + ], + ], $site->proxies()->all()); + } + public function test_add_proxy_clears_previous_proxy_certificate() { $config = Mockery::mock(Configuration::class); @@ -564,6 +650,121 @@ public function test_remove_proxy() $this->assertEquals([], $site->proxies()->all()); } + public function test_remove_multiple_proxies() + { + $config = Mockery::mock(Configuration::class); + $config->shouldReceive('read') + ->andReturn(['tld' => 'test', 'loopback' => VALET_LOOPBACK]); + + swap(Configuration::class, $config); + + swap(CommandLine::class, resolve(CommandLineFake::class)); + + /** @var FixturesSiteFake $site */ + $site = resolve(FixturesSiteFake::class); + + $site->useOutput(); + + $site->assertCertificateNotExists('my-new-proxy.com.test'); + $site->assertCertificateNotExists('my-other-new-proxy.com.test'); + $site->assertNginxNotExists('my-new-proxy.com.test'); + $site->assertNginxNotExists('my-other-new-proxy.com.test'); + + $this->assertEquals([], $site->proxies()->all()); + + $site->proxyCreate('my-new-proxy.com,my-other-new-proxy.com', 'https://127.0.0.1:9443', true); + + $this->assertEquals([ + 'my-new-proxy.com' => [ + 'site' => 'my-new-proxy.com', + 'secured' => ' X', + 'url' => 'https://my-new-proxy.com.test', + 'path' => 'https://127.0.0.1:9443', + ], + 'my-other-new-proxy.com' => [ + 'site' => 'my-other-new-proxy.com', + 'secured' => ' X', + 'url' => 'https://my-other-new-proxy.com.test', + 'path' => 'https://127.0.0.1:9443', + ], + ], $site->proxies()->all()); + + $site->assertCertificateExists('my-new-proxy.com.test'); + $site->assertCertificateExists('my-other-new-proxy.com.test'); + $site->assertNginxExists('my-new-proxy.com.test'); + $site->assertNginxExists('my-other-new-proxy.com.test'); + + $site->proxyDelete('my-new-proxy.com,my-other-new-proxy.com'); + + $site->assertCertificateNotExists('my-new-proxy.com.test'); + $site->assertCertificateNotExists('my-other-new-proxy.com.test'); + $site->assertNginxNotExists('my-new-proxy.com.test'); + $site->assertNginxNotExists('my-other-new-proxy.com.test'); + + $this->assertEquals([], $site->proxies()->all()); + } + + public function test_remove_single_proxy_from_multiple_proxies() + { + $config = Mockery::mock(Configuration::class); + $config->shouldReceive('read') + ->andReturn(['tld' => 'test', 'loopback' => VALET_LOOPBACK]); + + swap(Configuration::class, $config); + + swap(CommandLine::class, resolve(CommandLineFake::class)); + + /** @var FixturesSiteFake $site */ + $site = resolve(FixturesSiteFake::class); + + $site->useOutput(); + + $site->assertCertificateNotExists('my-new-proxy.com.test'); + $site->assertCertificateNotExists('my-other-new-proxy.com.test'); + $site->assertNginxNotExists('my-new-proxy.com.test'); + $site->assertNginxNotExists('my-other-new-proxy.com.test'); + + $this->assertEquals([], $site->proxies()->all()); + + $site->proxyCreate('my-new-proxy.com,my-other-new-proxy.com', 'https://127.0.0.1:9443', true); + + $this->assertEquals([ + 'my-new-proxy.com' => [ + 'site' => 'my-new-proxy.com', + 'secured' => ' X', + 'url' => 'https://my-new-proxy.com.test', + 'path' => 'https://127.0.0.1:9443', + ], + 'my-other-new-proxy.com' => [ + 'site' => 'my-other-new-proxy.com', + 'secured' => ' X', + 'url' => 'https://my-other-new-proxy.com.test', + 'path' => 'https://127.0.0.1:9443', + ], + ], $site->proxies()->all()); + + $site->assertCertificateExists('my-new-proxy.com.test'); + $site->assertCertificateExists('my-other-new-proxy.com.test'); + $site->assertNginxExists('my-new-proxy.com.test'); + $site->assertNginxExists('my-other-new-proxy.com.test'); + + $site->proxyDelete('my-new-proxy.com'); + + $site->assertCertificateNotExists('my-new-proxy.com.test'); + $site->assertCertificateExists('my-other-new-proxy.com.test'); + $site->assertNginxNotExists('my-new-proxy.com.test'); + $site->assertNginxExists('my-other-new-proxy.com.test'); + + $this->assertEquals([ + 'my-other-new-proxy.com' => [ + 'site' => 'my-other-new-proxy.com', + 'secured' => ' X', + 'url' => 'https://my-other-new-proxy.com.test', + 'path' => 'https://127.0.0.1:9443', + ], + ], $site->proxies()->all()); + } + public function test_gets_site_url_from_directory() { $config = Mockery::mock(Configuration::class); From 9a4a7a1693d3b4286146f65c6a607d0902191e63 Mon Sep 17 00:00:00 2001 From: mattstauffer Date: Sun, 27 Aug 2023 02:47:47 +0000 Subject: [PATCH 37/68] Fix code styling --- cli/app.php | 1 + tests/BrewTest.php | 1 + tests/CliTest.php | 3 ++- tests/ComposerTest.php | 1 + tests/ConfigurationTest.php | 3 ++- tests/DnsMasqTest.php | 1 + tests/NginxTest.php | 3 ++- tests/NgrokTest.php | 1 + tests/PhpFpmTest.php | 3 ++- tests/ServerTest.php | 1 + tests/SiteTest.php | 3 ++- tests/StatusTest.php | 3 ++- 12 files changed, 18 insertions(+), 6 deletions(-) diff --git a/cli/app.php b/cli/app.php index a70529082..2b9591829 100644 --- a/cli/app.php +++ b/cli/app.php @@ -10,6 +10,7 @@ use Symfony\Component\Console\Question\ConfirmationQuestion; use Symfony\Component\EventDispatcher\EventDispatcher; use Valet\Drivers\ValetDriver; + use function Valet\info; use function Valet\output; use function Valet\table; diff --git a/tests/BrewTest.php b/tests/BrewTest.php index f2cbee167..51b7b7855 100644 --- a/tests/BrewTest.php +++ b/tests/BrewTest.php @@ -5,6 +5,7 @@ use Valet\Brew; use Valet\CommandLine; use Valet\Filesystem; + use function Valet\resolve; use function Valet\swap; use function Valet\user; diff --git a/tests/CliTest.php b/tests/CliTest.php index cdc7e9a20..b902c13f5 100644 --- a/tests/CliTest.php +++ b/tests/CliTest.php @@ -11,9 +11,10 @@ use Valet\Ngrok; use Valet\PhpFpm; use Valet\Site as RealSite; -use function Valet\swap; use Valet\Valet; +use function Valet\swap; + /** * @requires PHP >= 8.0 */ diff --git a/tests/ComposerTest.php b/tests/ComposerTest.php index ad3642891..808ab40ef 100644 --- a/tests/ComposerTest.php +++ b/tests/ComposerTest.php @@ -3,6 +3,7 @@ use Illuminate\Container\Container; use Valet\CommandLine; use Valet\Composer; + use function Valet\resolve; use function Valet\swap; use function Valet\user; diff --git a/tests/ConfigurationTest.php b/tests/ConfigurationTest.php index 187e3026b..34acd4d90 100644 --- a/tests/ConfigurationTest.php +++ b/tests/ConfigurationTest.php @@ -4,10 +4,11 @@ use Valet\Brew; use Valet\Configuration; use Valet\Filesystem; +use Valet\Valet; + use function Valet\resolve; use function Valet\swap; use function Valet\user; -use Valet\Valet; class ConfigurationTest extends Yoast\PHPUnitPolyfills\TestCases\TestCase { diff --git a/tests/DnsMasqTest.php b/tests/DnsMasqTest.php index 5f9b58133..a6c99cf9b 100644 --- a/tests/DnsMasqTest.php +++ b/tests/DnsMasqTest.php @@ -6,6 +6,7 @@ use Valet\Configuration; use Valet\DnsMasq; use Valet\Filesystem; + use function Valet\resolve; use function Valet\swap; use function Valet\user; diff --git a/tests/NginxTest.php b/tests/NginxTest.php index 6b0141b09..facf94891 100644 --- a/tests/NginxTest.php +++ b/tests/NginxTest.php @@ -4,8 +4,9 @@ use Valet\Configuration; use Valet\Filesystem; use Valet\Nginx; -use function Valet\resolve; use Valet\Site; + +use function Valet\resolve; use function Valet\swap; use function Valet\user; diff --git a/tests/NgrokTest.php b/tests/NgrokTest.php index 23e61b726..7f37da617 100644 --- a/tests/NgrokTest.php +++ b/tests/NgrokTest.php @@ -2,6 +2,7 @@ use Illuminate\Container\Container; use Valet\Ngrok; + use function Valet\resolve; use function Valet\user; diff --git a/tests/PhpFpmTest.php b/tests/PhpFpmTest.php index eaea2bf29..9d4e50335 100644 --- a/tests/PhpFpmTest.php +++ b/tests/PhpFpmTest.php @@ -7,8 +7,9 @@ use Valet\Filesystem; use Valet\Nginx; use Valet\PhpFpm; -use function Valet\resolve; use Valet\Site; + +use function Valet\resolve; use function Valet\swap; use function Valet\user; diff --git a/tests/ServerTest.php b/tests/ServerTest.php index 8c4b16d4d..55243a92b 100644 --- a/tests/ServerTest.php +++ b/tests/ServerTest.php @@ -2,6 +2,7 @@ use Illuminate\Container\Container; use Valet\Server; + use function Valet\user; class ServerTest extends Yoast\PHPUnitPolyfills\TestCases\TestCase diff --git a/tests/SiteTest.php b/tests/SiteTest.php index 52b9e7d44..14b310e64 100644 --- a/tests/SiteTest.php +++ b/tests/SiteTest.php @@ -5,8 +5,9 @@ use Valet\CommandLine; use Valet\Configuration; use Valet\Filesystem; -use function Valet\resolve; use Valet\Site; + +use function Valet\resolve; use function Valet\swap; use function Valet\user; diff --git a/tests/StatusTest.php b/tests/StatusTest.php index d0bfb1d16..e1d196ec8 100644 --- a/tests/StatusTest.php +++ b/tests/StatusTest.php @@ -2,8 +2,9 @@ use Illuminate\Container\Container; use Valet\CommandLine; -use function Valet\resolve; use Valet\Status; + +use function Valet\resolve; use function Valet\swap; use function Valet\user; From e03de8856f9f57e5acc5220cc034dd8a8f404fde Mon Sep 17 00:00:00 2001 From: Matt Stauffer Date: Sun, 27 Aug 2023 11:13:47 -0400 Subject: [PATCH 38/68] Drop Mailhog and Redis from default logs list, since Valet doesn't install them --- cli/app.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/cli/app.php b/cli/app.php index 2b9591829..b78b5a381 100644 --- a/cli/app.php +++ b/cli/app.php @@ -728,8 +728,6 @@ function (ConsoleCommandEvent $event) { $defaultLogs = [ 'php-fpm' => BREW_PREFIX.'/var/log/php-fpm.log', 'nginx' => VALET_HOME_PATH.'/Log/nginx-error.log', - 'mailhog' => BREW_PREFIX.'/var/log/mailhog.log', - 'redis' => BREW_PREFIX.'/var/log/redis.log', ]; $configLogs = data_get(Configuration::read(), 'logs'); From cda54e17ea9b7bdc38bfc0310506884ba3c1241f Mon Sep 17 00:00:00 2001 From: Chris Brown Date: Sun, 27 Aug 2023 13:55:07 -0400 Subject: [PATCH 39/68] Allow LaravelValetDriver to serve other /public/*.php files When PHP files other than index.php exist in /public/ this allows them to be served by the Laravel driver. I discussed this previously at: https://github.com/laravel/valet/discussions/1430#discussioncomment-6536474 ... but I think it's safe to include in the core LaravelValetDriver by default. --- cli/Valet/Drivers/LaravelValetDriver.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cli/Valet/Drivers/LaravelValetDriver.php b/cli/Valet/Drivers/LaravelValetDriver.php index f5b8dedb4..22b576cc6 100644 --- a/cli/Valet/Drivers/LaravelValetDriver.php +++ b/cli/Valet/Drivers/LaravelValetDriver.php @@ -52,6 +52,11 @@ public function isStaticFile(string $sitePath, string $siteName, string $uri)/*: */ public function frontControllerPath(string $sitePath, string $siteName, string $uri): ?string { + if (file_exists($staticFilePath = $sitePath.'/public'.$uri) + && $this->isActualFile($staticFilePath)) { + return $staticFilePath; + } + return $sitePath.'/public/index.php'; } } From 12c10e0b03f9b4f8073e4d131bfbd89ce5d0a644 Mon Sep 17 00:00:00 2001 From: Jason Varga Date: Mon, 28 Aug 2023 14:38:42 -0400 Subject: [PATCH 40/68] add statamic driver --- .../Specific/StatamicV3ValetDriver.php | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 cli/Valet/Drivers/Specific/StatamicV3ValetDriver.php diff --git a/cli/Valet/Drivers/Specific/StatamicV3ValetDriver.php b/cli/Valet/Drivers/Specific/StatamicV3ValetDriver.php new file mode 100644 index 000000000..6543f4b45 --- /dev/null +++ b/cli/Valet/Drivers/Specific/StatamicV3ValetDriver.php @@ -0,0 +1,40 @@ +isActualFile($staticPath = $this->getStaticPath($sitePath))) { + return $staticPath; + } + + return parent::frontControllerPath($sitePath, $siteName, $uri); + } + + /** + * Get the path to the static file. + */ + protected function getStaticPath(string $sitePath): string + { + $parts = parse_url($_SERVER['REQUEST_URI']); + $query = $parts['query'] ?? ''; + + return $sitePath.'/public/static'.$parts['path'].'_'.$query.'.html'; + } +} From fadd0d46b89b7d7cdda2f90352765c3809992d86 Mon Sep 17 00:00:00 2001 From: Jason Varga Date: Mon, 28 Aug 2023 14:38:58 -0400 Subject: [PATCH 41/68] attempt statamic driver first --- cli/Valet/Drivers/ValetDriver.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cli/Valet/Drivers/ValetDriver.php b/cli/Valet/Drivers/ValetDriver.php index 7ce24987c..2dc5c45a3 100644 --- a/cli/Valet/Drivers/ValetDriver.php +++ b/cli/Valet/Drivers/ValetDriver.php @@ -45,8 +45,9 @@ public static function assign(string $sitePath, string $siteName, string $uri): $drivers = array_merge($drivers, static::customDrivers()); // Queue Valet-shipped drivers + $drivers[] = 'Specific\StatamicV3ValetDriver'; $drivers[] = 'LaravelValetDriver'; - $drivers = array_merge($drivers, $specificDrivers); + $drivers = array_unique(array_merge($drivers, $specificDrivers)); $drivers[] = 'BasicWithPublicValetDriver'; $drivers[] = 'BasicValetDriver'; From ee5391def6fb75bb89e59df6b340732b9deb9ae7 Mon Sep 17 00:00:00 2001 From: Jason Varga Date: Mon, 28 Aug 2023 15:14:38 -0400 Subject: [PATCH 42/68] rename --- .../Specific/StatamicV2ValetDriver.php | 127 ++++++++++++++++++ .../Specific/StatamicV3ValetDriver.php | 40 ------ .../Drivers/Specific/StatamicValetDriver.php | 107 ++------------- cli/Valet/Drivers/ValetDriver.php | 2 +- 4 files changed, 138 insertions(+), 138 deletions(-) create mode 100644 cli/Valet/Drivers/Specific/StatamicV2ValetDriver.php delete mode 100644 cli/Valet/Drivers/Specific/StatamicV3ValetDriver.php diff --git a/cli/Valet/Drivers/Specific/StatamicV2ValetDriver.php b/cli/Valet/Drivers/Specific/StatamicV2ValetDriver.php new file mode 100644 index 000000000..4eee35c01 --- /dev/null +++ b/cli/Valet/Drivers/Specific/StatamicV2ValetDriver.php @@ -0,0 +1,127 @@ +isActualFile($staticFilePath = $sitePath.$uri)) { + return $staticFilePath; + } elseif ($this->isActualFile($staticFilePath = $sitePath.'/public'.$uri)) { + return $staticFilePath; + } + + return false; + } + + /** + * Get the fully resolved path to the application's front controller. + */ + public function frontControllerPath(string $sitePath, string $siteName, string $uri): ?string + { + if ($_SERVER['REQUEST_METHOD'] === 'GET' && $this->isActualFile($staticPath = $this->getStaticPath($sitePath))) { + return $staticPath; + } + + if ($uri === '/installer.php') { + return $sitePath.'/installer.php'; + } + + $scriptName = '/index.php'; + + if ($this->isActualFile($sitePath.'/index.php')) { + $indexPath = $sitePath.'/index.php'; + } + + if ($isAboveWebroot = $this->isActualFile($sitePath.'/public/index.php')) { + $indexPath = $sitePath.'/public/index.php'; + } + + $sitePathPrefix = ($isAboveWebroot) ? $sitePath.'/public' : $sitePath; + + if ($locale = $this->getUriLocale($uri)) { + if ($this->isActualFile($localeIndexPath = $sitePathPrefix.'/'.$locale.'/index.php')) { + // Force trailing slashes on locale roots. + if ($uri === '/'.$locale) { + header('Location: '.$uri.'/'); + exit; + } + + $indexPath = $localeIndexPath; + $scriptName = '/'.$locale.'/index.php'; + } + } + + $_SERVER['SCRIPT_NAME'] = $scriptName; + $_SERVER['SCRIPT_FILENAME'] = $sitePathPrefix.$scriptName; + + return $indexPath; + } + + /** + * Get the locale from this URI. + */ + public function getUriLocale(string $uri): ?string + { + $parts = explode('/', $uri); + $locale = $parts[1]; + + if (count($parts) < 2 || ! in_array($locale, $this->getLocales())) { + return null; + } + + return $locale; + } + + /** + * Get the list of possible locales used in the first segment of a URI. + */ + public function getLocales(): array + { + return [ + 'af', 'ax', 'al', 'dz', 'as', 'ad', 'ao', 'ai', 'aq', 'ag', 'ar', 'am', 'aw', 'au', 'at', 'az', 'bs', 'bh', + 'bd', 'bb', 'by', 'be', 'bz', 'bj', 'bm', 'bt', 'bo', 'bq', 'ba', 'bw', 'bv', 'br', 'io', 'bn', 'bg', 'bf', + 'bi', 'cv', 'kh', 'cm', 'ca', 'ky', 'cf', 'td', 'cl', 'cn', 'cx', 'cc', 'co', 'km', 'cg', 'cd', 'ck', 'cr', + 'ci', 'hr', 'cu', 'cw', 'cy', 'cz', 'dk', 'dj', 'dm', 'do', 'ec', 'eg', 'sv', 'gq', 'er', 'ee', 'et', 'fk', + 'fo', 'fj', 'fi', 'fr', 'gf', 'pf', 'tf', 'ga', 'gm', 'ge', 'de', 'gh', 'gi', 'gr', 'gl', 'gd', 'gp', 'gu', + 'gt', 'gg', 'gn', 'gw', 'gy', 'ht', 'hm', 'va', 'hn', 'hk', 'hu', 'is', 'in', 'id', 'ir', 'iq', 'ie', 'im', + 'il', 'it', 'jm', 'jp', 'je', 'jo', 'kz', 'ke', 'ki', 'kp', 'kr', 'kw', 'kg', 'la', 'lv', 'lb', 'ls', 'lr', + 'ly', 'li', 'lt', 'lu', 'mo', 'mk', 'mg', 'mw', 'my', 'mv', 'ml', 'mt', 'mh', 'mq', 'mr', 'mu', 'yt', 'mx', + 'fm', 'md', 'mc', 'mn', 'me', 'ms', 'ma', 'mz', 'mm', 'na', 'nr', 'np', 'nl', 'nc', 'nz', 'ni', 'ne', 'ng', + 'nu', 'nf', 'mp', 'no', 'om', 'pk', 'pw', 'ps', 'pa', 'pg', 'py', 'pe', 'ph', 'pn', 'pl', 'pt', 'pr', 'qa', + 're', 'ro', 'ru', 'rw', 'bl', 'sh', 'kn', 'lc', 'mf', 'pm', 'vc', 'ws', 'sm', 'st', 'sa', 'sn', 'rs', 'sc', + 'sl', 'sg', 'sx', 'sk', 'si', 'sb', 'so', 'za', 'gs', 'ss', 'es', 'lk', 'sd', 'sr', 'sj', 'sz', 'se', 'ch', + 'sy', 'tw', 'tj', 'tz', 'th', 'tl', 'tg', 'tk', 'to', 'tt', 'tn', 'tr', 'tm', 'tc', 'tv', 'ug', 'ua', 'ae', + 'gb', 'us', 'um', 'uy', 'uz', 'vu', 've', 'vn', 'vg', 'vi', 'wf', 'eh', 'ye', 'zm', 'zw', 'en', 'zh', + ]; + } + + /** + * Get the path to a statically cached page. + */ + protected function getStaticPath(string $sitePath): string + { + $parts = parse_url($_SERVER['REQUEST_URI']); + $query = isset($parts['query']) ? $parts['query'] : ''; + + return $sitePath.'/static'.$parts['path'].'_'.$query.'.html'; + } +} diff --git a/cli/Valet/Drivers/Specific/StatamicV3ValetDriver.php b/cli/Valet/Drivers/Specific/StatamicV3ValetDriver.php deleted file mode 100644 index 6543f4b45..000000000 --- a/cli/Valet/Drivers/Specific/StatamicV3ValetDriver.php +++ /dev/null @@ -1,40 +0,0 @@ -isActualFile($staticPath = $this->getStaticPath($sitePath))) { - return $staticPath; - } - - return parent::frontControllerPath($sitePath, $siteName, $uri); - } - - /** - * Get the path to the static file. - */ - protected function getStaticPath(string $sitePath): string - { - $parts = parse_url($_SERVER['REQUEST_URI']); - $query = $parts['query'] ?? ''; - - return $sitePath.'/public/static'.$parts['path'].'_'.$query.'.html'; - } -} diff --git a/cli/Valet/Drivers/Specific/StatamicValetDriver.php b/cli/Valet/Drivers/Specific/StatamicValetDriver.php index 7392a6add..208a24b23 100644 --- a/cli/Valet/Drivers/Specific/StatamicValetDriver.php +++ b/cli/Valet/Drivers/Specific/StatamicValetDriver.php @@ -2,126 +2,39 @@ namespace Valet\Drivers\Specific; -use Valet\Drivers\ValetDriver; +use Valet\Drivers\LaravelValetDriver; -class StatamicValetDriver extends ValetDriver +class StatamicValetDriver extends LaravelValetDriver { /** * Determine if the driver serves the request. */ public function serves(string $sitePath, string $siteName, string $uri): bool { - return is_dir($sitePath.'/statamic'); - } - - /** - * Determine if the incoming request is for a static file. - */ - public function isStaticFile(string $sitePath, string $siteName, string $uri)/*: string|false */ - { - if (strpos($uri, '/site') === 0 && strpos($uri, '/site/themes') !== 0) { - return false; - } elseif (strpos($uri, '/local') === 0 || strpos($uri, '/statamic') === 0) { - return false; - } elseif ($this->isActualFile($staticFilePath = $sitePath.$uri)) { - return $staticFilePath; - } elseif ($this->isActualFile($staticFilePath = $sitePath.'/public'.$uri)) { - return $staticFilePath; - } - - return false; + return file_exists($sitePath.'/please') + && parent::serves($sitePath, $siteName, $uri); } /** * Get the fully resolved path to the application's front controller. */ - public function frontControllerPath(string $sitePath, string $siteName, string $uri): ?string + public function frontControllerPath(string $sitePath, string $siteName, string $uri): string { - if ($_SERVER['REQUEST_METHOD'] === 'GET' && $this->isActualFile($staticPath = $this->getStaticPath($sitePath))) { + if ($this->isActualFile($staticPath = $this->getStaticPath($sitePath))) { return $staticPath; } - if ($uri === '/installer.php') { - return $sitePath.'/installer.php'; - } - - $scriptName = '/index.php'; - - if ($this->isActualFile($sitePath.'/index.php')) { - $indexPath = $sitePath.'/index.php'; - } - - if ($isAboveWebroot = $this->isActualFile($sitePath.'/public/index.php')) { - $indexPath = $sitePath.'/public/index.php'; - } - - $sitePathPrefix = ($isAboveWebroot) ? $sitePath.'/public' : $sitePath; - - if ($locale = $this->getUriLocale($uri)) { - if ($this->isActualFile($localeIndexPath = $sitePathPrefix.'/'.$locale.'/index.php')) { - // Force trailing slashes on locale roots. - if ($uri === '/'.$locale) { - header('Location: '.$uri.'/'); - exit; - } - - $indexPath = $localeIndexPath; - $scriptName = '/'.$locale.'/index.php'; - } - } - - $_SERVER['SCRIPT_NAME'] = $scriptName; - $_SERVER['SCRIPT_FILENAME'] = $sitePathPrefix.$scriptName; - - return $indexPath; - } - - /** - * Get the locale from this URI. - */ - public function getUriLocale(string $uri): ?string - { - $parts = explode('/', $uri); - $locale = $parts[1]; - - if (count($parts) < 2 || ! in_array($locale, $this->getLocales())) { - return null; - } - - return $locale; - } - - /** - * Get the list of possible locales used in the first segment of a URI. - */ - public function getLocales(): array - { - return [ - 'af', 'ax', 'al', 'dz', 'as', 'ad', 'ao', 'ai', 'aq', 'ag', 'ar', 'am', 'aw', 'au', 'at', 'az', 'bs', 'bh', - 'bd', 'bb', 'by', 'be', 'bz', 'bj', 'bm', 'bt', 'bo', 'bq', 'ba', 'bw', 'bv', 'br', 'io', 'bn', 'bg', 'bf', - 'bi', 'cv', 'kh', 'cm', 'ca', 'ky', 'cf', 'td', 'cl', 'cn', 'cx', 'cc', 'co', 'km', 'cg', 'cd', 'ck', 'cr', - 'ci', 'hr', 'cu', 'cw', 'cy', 'cz', 'dk', 'dj', 'dm', 'do', 'ec', 'eg', 'sv', 'gq', 'er', 'ee', 'et', 'fk', - 'fo', 'fj', 'fi', 'fr', 'gf', 'pf', 'tf', 'ga', 'gm', 'ge', 'de', 'gh', 'gi', 'gr', 'gl', 'gd', 'gp', 'gu', - 'gt', 'gg', 'gn', 'gw', 'gy', 'ht', 'hm', 'va', 'hn', 'hk', 'hu', 'is', 'in', 'id', 'ir', 'iq', 'ie', 'im', - 'il', 'it', 'jm', 'jp', 'je', 'jo', 'kz', 'ke', 'ki', 'kp', 'kr', 'kw', 'kg', 'la', 'lv', 'lb', 'ls', 'lr', - 'ly', 'li', 'lt', 'lu', 'mo', 'mk', 'mg', 'mw', 'my', 'mv', 'ml', 'mt', 'mh', 'mq', 'mr', 'mu', 'yt', 'mx', - 'fm', 'md', 'mc', 'mn', 'me', 'ms', 'ma', 'mz', 'mm', 'na', 'nr', 'np', 'nl', 'nc', 'nz', 'ni', 'ne', 'ng', - 'nu', 'nf', 'mp', 'no', 'om', 'pk', 'pw', 'ps', 'pa', 'pg', 'py', 'pe', 'ph', 'pn', 'pl', 'pt', 'pr', 'qa', - 're', 'ro', 'ru', 'rw', 'bl', 'sh', 'kn', 'lc', 'mf', 'pm', 'vc', 'ws', 'sm', 'st', 'sa', 'sn', 'rs', 'sc', - 'sl', 'sg', 'sx', 'sk', 'si', 'sb', 'so', 'za', 'gs', 'ss', 'es', 'lk', 'sd', 'sr', 'sj', 'sz', 'se', 'ch', - 'sy', 'tw', 'tj', 'tz', 'th', 'tl', 'tg', 'tk', 'to', 'tt', 'tn', 'tr', 'tm', 'tc', 'tv', 'ug', 'ua', 'ae', - 'gb', 'us', 'um', 'uy', 'uz', 'vu', 've', 'vn', 'vg', 'vi', 'wf', 'eh', 'ye', 'zm', 'zw', 'en', 'zh', - ]; + return parent::frontControllerPath($sitePath, $siteName, $uri); } /** - * Get the path to a statically cached page. + * Get the path to the static file. */ protected function getStaticPath(string $sitePath): string { $parts = parse_url($_SERVER['REQUEST_URI']); - $query = isset($parts['query']) ? $parts['query'] : ''; + $query = $parts['query'] ?? ''; - return $sitePath.'/static'.$parts['path'].'_'.$query.'.html'; + return $sitePath.'/public/static'.$parts['path'].'_'.$query.'.html'; } } diff --git a/cli/Valet/Drivers/ValetDriver.php b/cli/Valet/Drivers/ValetDriver.php index 2dc5c45a3..9d6fff1a8 100644 --- a/cli/Valet/Drivers/ValetDriver.php +++ b/cli/Valet/Drivers/ValetDriver.php @@ -45,7 +45,7 @@ public static function assign(string $sitePath, string $siteName, string $uri): $drivers = array_merge($drivers, static::customDrivers()); // Queue Valet-shipped drivers - $drivers[] = 'Specific\StatamicV3ValetDriver'; + $drivers[] = 'Specific\StatamicValetDriver'; $drivers[] = 'LaravelValetDriver'; $drivers = array_unique(array_merge($drivers, $specificDrivers)); $drivers[] = 'BasicWithPublicValetDriver'; From a93f267c0398a288c7e0ba5c35290d011096cc91 Mon Sep 17 00:00:00 2001 From: Jason Varga Date: Mon, 28 Aug 2023 15:40:33 -0400 Subject: [PATCH 43/68] adjust tests --- tests/Drivers/StatamicV2ValetDriverTest.php | 31 +++++++++++++++++++ tests/Drivers/StatamicValetDriverTest.php | 16 ++++++---- .../statamic/{statamic/.gitkeep => artisan} | 0 tests/Drivers/projects/statamic/please | 0 .../projects/statamic/public/index.php | 0 .../statamic/public/static/test_.html | 0 .../public/static/test_foo=bar&baz=qux.html | 0 tests/Drivers/projects/statamicv2/index.php | 0 .../projects/statamicv2/statamic/.gitkeep | 0 9 files changed, 41 insertions(+), 6 deletions(-) create mode 100644 tests/Drivers/StatamicV2ValetDriverTest.php rename tests/Drivers/projects/statamic/{statamic/.gitkeep => artisan} (100%) create mode 100644 tests/Drivers/projects/statamic/please create mode 100644 tests/Drivers/projects/statamic/public/index.php create mode 100644 tests/Drivers/projects/statamic/public/static/test_.html create mode 100644 tests/Drivers/projects/statamic/public/static/test_foo=bar&baz=qux.html create mode 100644 tests/Drivers/projects/statamicv2/index.php create mode 100644 tests/Drivers/projects/statamicv2/statamic/.gitkeep diff --git a/tests/Drivers/StatamicV2ValetDriverTest.php b/tests/Drivers/StatamicV2ValetDriverTest.php new file mode 100644 index 000000000..630e6d1d6 --- /dev/null +++ b/tests/Drivers/StatamicV2ValetDriverTest.php @@ -0,0 +1,31 @@ +assertTrue($driver->serves($this->projectDir('statamicv2'), 'my-site', '/')); + } + + public function test_it_doesnt_serve_non_statamic_projects() + { + $driver = new StatamicV2ValetDriver(); + + $this->assertFalse($driver->serves($this->projectDir('public-with-index-non-laravel'), 'my-site', '/')); + } + + public function test_it_gets_front_controller() + { + $driver = new StatamicV2ValetDriver(); + + $_SERVER['REQUEST_METHOD'] = 'GET'; + $_SERVER['REQUEST_URI'] = '/about/'; + + $projectPath = $this->projectDir('statamicv2'); + $this->assertEquals($projectPath.'/index.php', $driver->frontControllerPath($projectPath, 'my-site', '/')); + } +} diff --git a/tests/Drivers/StatamicValetDriverTest.php b/tests/Drivers/StatamicValetDriverTest.php index ecd0eedca..5b412388d 100644 --- a/tests/Drivers/StatamicValetDriverTest.php +++ b/tests/Drivers/StatamicValetDriverTest.php @@ -11,21 +11,25 @@ public function test_it_serves_statamic_projects() $this->assertTrue($driver->serves($this->projectDir('statamic'), 'my-site', '/')); } - public function test_it_doesnt_serve_non_statamic_projects() + public function test_it_doesnt_serve_non_statamic_projects_with_public_directory() { $driver = new StatamicValetDriver(); $this->assertFalse($driver->serves($this->projectDir('public-with-index-non-laravel'), 'my-site', '/')); } - public function test_it_gets_front_controller() + public function test_it_doesnt_serve_laravel_projects() { $driver = new StatamicValetDriver(); - $_SERVER['REQUEST_METHOD'] = 'GET'; - $_SERVER['REQUEST_URI'] = '/about/'; + $this->assertFalse($driver->serves($this->projectDir('laravel'), 'my-site', '/')); + } + + public function test_it_gets_front_controller() + { + $driver = new StatamicValetDriver(); - $projectPath = $this->projectDir('statamicv1'); - $this->assertEquals($projectPath.'/index.php', $driver->frontControllerPath($projectPath, 'my-site', '/')); + $projectPath = $this->projectDir('statamic'); + $this->assertEquals($projectPath.'/public/index.php', $driver->frontControllerPath($projectPath, 'my-site', '/')); } } diff --git a/tests/Drivers/projects/statamic/statamic/.gitkeep b/tests/Drivers/projects/statamic/artisan similarity index 100% rename from tests/Drivers/projects/statamic/statamic/.gitkeep rename to tests/Drivers/projects/statamic/artisan diff --git a/tests/Drivers/projects/statamic/please b/tests/Drivers/projects/statamic/please new file mode 100644 index 000000000..e69de29bb diff --git a/tests/Drivers/projects/statamic/public/index.php b/tests/Drivers/projects/statamic/public/index.php new file mode 100644 index 000000000..e69de29bb diff --git a/tests/Drivers/projects/statamic/public/static/test_.html b/tests/Drivers/projects/statamic/public/static/test_.html new file mode 100644 index 000000000..e69de29bb diff --git a/tests/Drivers/projects/statamic/public/static/test_foo=bar&baz=qux.html b/tests/Drivers/projects/statamic/public/static/test_foo=bar&baz=qux.html new file mode 100644 index 000000000..e69de29bb diff --git a/tests/Drivers/projects/statamicv2/index.php b/tests/Drivers/projects/statamicv2/index.php new file mode 100644 index 000000000..e69de29bb diff --git a/tests/Drivers/projects/statamicv2/statamic/.gitkeep b/tests/Drivers/projects/statamicv2/statamic/.gitkeep new file mode 100644 index 000000000..e69de29bb From e52b9014158ebe55946383422788374a38f7a588 Mon Sep 17 00:00:00 2001 From: Jason Varga Date: Mon, 28 Aug 2023 15:41:41 -0400 Subject: [PATCH 44/68] add test for static caching --- tests/Drivers/StatamicValetDriverTest.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/Drivers/StatamicValetDriverTest.php b/tests/Drivers/StatamicValetDriverTest.php index 5b412388d..5d2f0eed0 100644 --- a/tests/Drivers/StatamicValetDriverTest.php +++ b/tests/Drivers/StatamicValetDriverTest.php @@ -32,4 +32,17 @@ public function test_it_gets_front_controller() $projectPath = $this->projectDir('statamic'); $this->assertEquals($projectPath.'/public/index.php', $driver->frontControllerPath($projectPath, 'my-site', '/')); } + + public function test_it_serves_statically_cached_pages() + { + $driver = new StatamicValetDriver(); + + $projectPath = $this->projectDir('statamic'); + + $_SERVER['REQUEST_URI'] = '/test'; + $this->assertEquals($projectPath.'/public/static/test_.html', $driver->frontControllerPath($projectPath, 'my-site', '/test')); + + $_SERVER['REQUEST_URI'] = '/test?foo=bar&baz=qux'; + $this->assertEquals($projectPath.'/public/static/test_foo=bar&baz=qux.html', $driver->frontControllerPath($projectPath, 'my-site', '/test')); + } } From b55140a079315a16fc0e3071036b73639b3ba3a4 Mon Sep 17 00:00:00 2001 From: Jason Varga Date: Mon, 28 Aug 2023 15:42:12 -0400 Subject: [PATCH 45/68] adjust so that server variable doesnt need to be defined in all tests --- cli/Valet/Drivers/Specific/StatamicValetDriver.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/cli/Valet/Drivers/Specific/StatamicValetDriver.php b/cli/Valet/Drivers/Specific/StatamicValetDriver.php index 208a24b23..cb233d55f 100644 --- a/cli/Valet/Drivers/Specific/StatamicValetDriver.php +++ b/cli/Valet/Drivers/Specific/StatamicValetDriver.php @@ -20,7 +20,9 @@ public function serves(string $sitePath, string $siteName, string $uri): bool */ public function frontControllerPath(string $sitePath, string $siteName, string $uri): string { - if ($this->isActualFile($staticPath = $this->getStaticPath($sitePath))) { + $staticPath = $this->getStaticPath($sitePath); + + if ($staticPath && $this->isActualFile($staticPath)) { return $staticPath; } @@ -30,9 +32,13 @@ public function frontControllerPath(string $sitePath, string $siteName, string $ /** * Get the path to the static file. */ - protected function getStaticPath(string $sitePath): string + private function getStaticPath(string $sitePath) { - $parts = parse_url($_SERVER['REQUEST_URI']); + if (! $uri = $_SERVER['REQUEST_URI'] ?? null) { + return; + } + + $parts = parse_url($uri); $query = $parts['query'] ?? ''; return $sitePath.'/public/static'.$parts['path'].'_'.$query.'.html'; From df9e1effe4850d01e375dda3a94c46acbfd8b239 Mon Sep 17 00:00:00 2001 From: Jason Varga Date: Mon, 28 Aug 2023 16:09:24 -0400 Subject: [PATCH 46/68] priority test --- tests/Drivers/ValetDriverTest.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/Drivers/ValetDriverTest.php b/tests/Drivers/ValetDriverTest.php index 4f71bfc47..74360a905 100644 --- a/tests/Drivers/ValetDriverTest.php +++ b/tests/Drivers/ValetDriverTest.php @@ -30,6 +30,15 @@ public function test_it_prioritizes_non_basic_matches() $this->assertNotEquals('Valet\Drivers\BasicValetDriver', get_class($assignedDriver)); } + public function test_it_prioritizes_statamic() + { + $assignedDriver = ValetDriver::assign($this->projectDir('statamic'), 'my-site', '/'); + $this->assertEquals('Valet\Drivers\Specific\StatamicValetDriver', get_class($assignedDriver)); + + $assignedDriver = ValetDriver::assign($this->projectDir('laravel'), 'my-site', '/'); + $this->assertEquals('Valet\Drivers\LaravelValetDriver', get_class($assignedDriver)); + } + public function test_it_checks_composer_dependencies() { $driver = new BasicValetDriver; From 11c6ae1206b314cd2a542a599677ac5017c1fca6 Mon Sep 17 00:00:00 2001 From: Dries Vints Date: Tue, 29 Aug 2023 17:32:16 +0200 Subject: [PATCH 47/68] Update app.php --- cli/app.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/app.php b/cli/app.php index 2b9591829..0facd896f 100644 --- a/cli/app.php +++ b/cli/app.php @@ -33,7 +33,7 @@ */ Container::setInstance(new Container); -$version = '4.1.4'; +$version = '4.2.0'; $app = new Application('Laravel Valet', $version); From 92c135e2dd8f7e55af8a879730cd1d1487275467 Mon Sep 17 00:00:00 2001 From: Dries Vints Date: Tue, 5 Sep 2023 17:49:55 +0200 Subject: [PATCH 48/68] Update app.php --- cli/app.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/app.php b/cli/app.php index 318ecae49..c5edfe5af 100644 --- a/cli/app.php +++ b/cli/app.php @@ -33,7 +33,7 @@ */ Container::setInstance(new Container); -$version = '4.2.0'; +$version = '4.3.0'; $app = new Application('Laravel Valet', $version); From f37a474700b3320db7a201d26952fce4e81c4d10 Mon Sep 17 00:00:00 2001 From: driesvints Date: Tue, 5 Sep 2023 15:50:18 +0000 Subject: [PATCH 49/68] Fix code styling --- cli/Valet/Drivers/Specific/Magento2ValetDriver.php | 8 ++++---- cli/Valet/PhpFpm.php | 2 +- cli/Valet/Server.php | 6 +++--- cli/Valet/Site.php | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/cli/Valet/Drivers/Specific/Magento2ValetDriver.php b/cli/Valet/Drivers/Specific/Magento2ValetDriver.php index 1651926d1..ad25b67ab 100644 --- a/cli/Valet/Drivers/Specific/Magento2ValetDriver.php +++ b/cli/Valet/Drivers/Specific/Magento2ValetDriver.php @@ -34,7 +34,7 @@ public function isStaticFile(string $sitePath, string $siteName, string $uri)/*: $route = parse_url(substr($uri, 1))['path']; $pub = ''; - if ('developer' === $this->mageMode) { + if ($this->mageMode === 'developer') { $pub = 'pub/'; } @@ -43,7 +43,7 @@ public function isStaticFile(string $sitePath, string $siteName, string $uri)/*: } $magentoPackagePubDir = $sitePath; - if ('developer' !== $this->mageMode) { + if ($this->mageMode !== 'developer') { $magentoPackagePubDir .= '/pub'; } @@ -82,7 +82,7 @@ private function handleForVersions($route): string */ private function checkMageMode($sitePath): void { - if (null !== $this->mageMode) { + if ($this->mageMode !== null) { // We have already figure out mode, no need to check it again return; } @@ -131,7 +131,7 @@ public function frontControllerPath(string $sitePath, string $siteName, string $ { $this->checkMageMode($sitePath); - if ('developer' === $this->mageMode) { + if ($this->mageMode === 'developer') { $_SERVER['DOCUMENT_ROOT'] = $sitePath; return $sitePath.'/index.php'; diff --git a/cli/Valet/PhpFpm.php b/cli/Valet/PhpFpm.php index f88cd6693..75c92d896 100644 --- a/cli/Valet/PhpFpm.php +++ b/cli/Valet/PhpFpm.php @@ -224,7 +224,7 @@ public function useVersion(string $version, bool $force = false): ?string $version = $this->validateRequestedVersion($version); try { - if ($this->brew->linkedPhp() === $version && ! $force) { + if ($version === $this->brew->linkedPhp() && ! $force) { output(sprintf('Valet is already using version: %s. To re-link and re-configure use the --force parameter.'.PHP_EOL, $version)); exit(); diff --git a/cli/Valet/Server.php b/cli/Valet/Server.php index 85c37ed9a..0436f5c6a 100644 --- a/cli/Valet/Server.php +++ b/cli/Valet/Server.php @@ -168,7 +168,7 @@ public function sitePath(string $siteName): ?string $dirs = []; - while (false !== ($file = readdir($handle))) { + while (($file = readdir($handle)) !== false) { if (is_dir($path.'/'.$file) && ! in_array($file, ['.', '..'])) { $dirs[] = $file; } @@ -178,12 +178,12 @@ public function sitePath(string $siteName): ?string // Note: strtolower used below because Nginx only tells us lowercase names foreach ($dirs as $dir) { - if (strtolower($dir) === $siteName) { + if ($siteName === strtolower($dir)) { // early return when exact match for linked subdomain return $path.'/'.$dir; } - if (strtolower($dir) === $domain) { + if ($domain === strtolower($dir)) { // no early return here because the foreach may still have some subdomains to process with higher priority $valetSitePath = $path.'/'.$dir; } diff --git a/cli/Valet/Site.php b/cli/Valet/Site.php index f17825109..f7af2512e 100644 --- a/cli/Valet/Site.php +++ b/cli/Valet/Site.php @@ -52,7 +52,7 @@ private function getLinkNameByCurrentDir(): ?string public function host(string $path): ?string { foreach ($this->files->scandir($this->sitesPath()) as $link) { - if (realpath($this->sitesPath($link)) === $path) { + if ($path === realpath($this->sitesPath($link))) { return $link; } } From cdc8c19eff1bfef2494e7677cd067d7121a3e3a9 Mon Sep 17 00:00:00 2001 From: driesvints Date: Tue, 5 Sep 2023 15:50:38 +0000 Subject: [PATCH 50/68] Update CHANGELOG --- CHANGELOG.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bd8646ea2..28aa5ad2f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,11 @@ # Release Notes -## [Unreleased](https://github.com/laravel/valet/compare/v4.1.4...master) +## [Unreleased](https://github.com/laravel/valet/compare/v4.3.0...master) + +## [v4.3.0](https://github.com/laravel/valet/compare/v4.1.4...v4.3.0) - 2023-09-05 + +- Add "valet stop dnsmasq" option by [@drbyte](https://github.com/drbyte) in https://github.com/laravel/valet/pull/1422 +- Drop Mailhog and Redis from default logs list, since Valet doesn't install them by [@mattstauffer](https://github.com/mattstauffer) in https://github.com/laravel/valet/pull/1438 ## [v4.1.4](https://github.com/laravel/valet/compare/v4.1.3...v4.1.4) - 2023-08-14 From f378dc75de31c104824e31a2ee88d8541a1fb454 Mon Sep 17 00:00:00 2001 From: Chauncey McAskill Date: Sun, 16 Jul 2023 13:39:28 -0400 Subject: [PATCH 51/68] Improve link command's secure and isolate sub-commands Passing a custom hostname to the `link` command with the `--isolate` argument will result in either a mismatched site being isolated or the site not being found ("The [example] site could not be found in Valet's site list."). The reason for this is because the `isolate` command defaults to using the current directory's _name_ which won't match the custom hostname. This issue does not affect the `secure` command because it resolves the hostname from the current directory's _full path_. This commit passes the hostname (either custom or the current directory's name) to both sub-commands to ensure consistency of operations. Note: A bug introduced in mnapoli/silly v1.8.1 breaks all arguments in `runCommand()` method. See mnapoli/silly#69 for details and mnapoli/silly#70 for pull request. --- cli/app.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cli/app.php b/cli/app.php index c5edfe5af..380fb1495 100644 --- a/cli/app.php +++ b/cli/app.php @@ -197,12 +197,12 @@ function (ConsoleCommandEvent $event) { info('A ['.$name.'] symbolic link has been created in ['.$linkPath.'].'); if ($secure) { - $this->runCommand('secure'); + $this->runCommand('secure '.$name); } if ($isolate) { if (Site::phpRcVersion($name)) { - $this->runCommand('isolate'); + $this->runCommand('isolate --site='.$name); } else { warning('Valet could not determine which PHP version to use for this site.'); } From a268179535642fc7052532c049deb1b0a0878081 Mon Sep 17 00:00:00 2001 From: Chauncey McAskill Date: Sun, 16 Jul 2023 14:56:10 -0400 Subject: [PATCH 52/68] Ensure link command checks current directory for PHP version This matches the isolate command's usage of `Site::phpRcVersion()`. --- cli/app.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/app.php b/cli/app.php index 380fb1495..3aa0c0013 100644 --- a/cli/app.php +++ b/cli/app.php @@ -201,7 +201,7 @@ function (ConsoleCommandEvent $event) { } if ($isolate) { - if (Site::phpRcVersion($name)) { + if (Site::phpRcVersion($name, getcwd())) { $this->runCommand('isolate --site='.$name); } else { warning('Valet could not determine which PHP version to use for this site.'); From 24e7ed8ab94fbe386ea9c93598271ad065d32169 Mon Sep 17 00:00:00 2001 From: Chauncey McAskill Date: Sun, 16 Jul 2023 14:57:31 -0400 Subject: [PATCH 53/68] Add test of link command's isolate flag Based on `PhpFpmTest::test_isolate_will_isolate_a_site()` and `CliTest::test_link_command_with_secure_flag_secures()`. --- tests/CliTest.php | 65 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/tests/CliTest.php b/tests/CliTest.php index b902c13f5..52d4abdda 100644 --- a/tests/CliTest.php +++ b/tests/CliTest.php @@ -10,6 +10,7 @@ use Valet\Nginx; use Valet\Ngrok; use Valet\PhpFpm; +use function Valet\resolve; use Valet\Site as RealSite; use Valet\Valet; @@ -254,6 +255,70 @@ public function test_link_command_with_secure_flag_secures() $this->assertStringContainsString('site has been secured', $tester->getDisplay()); } + public function test_link_command_with_isolate_flag_isolates() + { + [$app, $tester] = $this->appAndTester(); + + $cwd = getcwd(); + $name = 'tighten'; + $host = $name.'.test'; + + $customPhpVersion = '82'; + $phpRcVersion = '8.2'; + $fullPhpVersion = 'php@8.2'; + + $brewMock = Mockery::mock(Brew::class); + $nginxMock = Mockery::mock(Nginx::class); + $siteMock = Mockery::mock(RealSite::class); + + $phpFpmMock = Mockery::mock(PhpFpm::class, [ + $brewMock, + resolve(CommandLine::class), + resolve(Filesystem::class), + resolve(RealConfiguration::class), + $siteMock, + $nginxMock, + ])->makePartial(); + + swap(Brew::class, $brewMock); + swap(Nginx::class, $nginxMock); + swap(PhpFpm::class, $phpFpmMock); + swap(RealSite::class, $siteMock); + + $brewMock->shouldReceive('supportedPhpVersions')->andReturn(collect([ + 'php@8.2', + 'php@8.1', + ])); + + $brewMock->shouldReceive('ensureInstalled')->with($fullPhpVersion, [], $phpFpmMock->taps); + $brewMock->shouldReceive('installed')->with($fullPhpVersion); + $brewMock->shouldReceive('determineAliasedVersion')->with($fullPhpVersion)->andReturn($fullPhpVersion); + + $siteMock->shouldReceive('link')->with($cwd, $name)->once(); + $siteMock->shouldReceive('getSiteUrl')->with($name)->andReturn($host); + $siteMock->shouldReceive('phpRcVersion')->with($name, $cwd)->andReturn($phpRcVersion); + $siteMock->shouldReceive('customPhpVersion')->with($host)->andReturn($customPhpVersion); + $siteMock->shouldReceive('isolate')->with($host, $fullPhpVersion); + + $phpFpmMock->shouldReceive('stopIfUnused')->with($customPhpVersion)->once(); + $phpFpmMock->shouldReceive('createConfigurationFiles')->with($fullPhpVersion)->once(); + $phpFpmMock->shouldReceive('restart')->with($fullPhpVersion)->once(); + + $nginxMock->shouldReceive('restart')->once(); + + // These should only run when doing global PHP switches + $brewMock->shouldNotReceive('stopService'); + $brewMock->shouldNotReceive('link'); + $brewMock->shouldNotReceive('unlink'); + $phpFpmMock->shouldNotReceive('stopRunning'); + $phpFpmMock->shouldNotReceive('install'); + + $tester->run(['command' => 'link', 'name' => 'tighten', '--isolate' => true]); + $tester->assertCommandIsSuccessful(); + + $this->assertStringContainsString('is now using '.$fullPhpVersion, $tester->getDisplay()); + } + public function test_links_command() { [$app, $tester] = $this->appAndTester(); From 35539feef491cd2a31f7b8fb34bcbef61476a57e Mon Sep 17 00:00:00 2001 From: Chauncey McAskill Date: Mon, 17 Jul 2023 09:06:57 -0400 Subject: [PATCH 54/68] Bump requirement for mnapoli/silly to 1.5+ Silly v1.5.0 introduced improvements on command arguments and options that are used by Valet. --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index c72ddd3d0..383755040 100644 --- a/composer.json +++ b/composer.json @@ -38,7 +38,7 @@ "php": "^7.1|^8.0", "illuminate/collections": "^8.0|^9.0|^10.0", "illuminate/container": "~5.1|^6.0|^7.0|^8.0|^9.0|^10.0", - "mnapoli/silly": "^1.0", + "mnapoli/silly": "^1.5", "symfony/console": "^3.0|^4.0|^5.0|^6.0", "symfony/process": "^3.0|^4.0|^5.0|^6.0", "guzzlehttp/guzzle": "^6.0|^7.4", From c02361beb13c0b8b69aa38c82929a2cd7cd632b8 Mon Sep 17 00:00:00 2001 From: Chauncey McAskill Date: Mon, 17 Jul 2023 09:07:57 -0400 Subject: [PATCH 55/68] =?UTF-8?q?Add=20conflict=20about=20mnapoli/silly=20?= =?UTF-8?q?1.8.1=E2=80=931.8.2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- composer.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/composer.json b/composer.json index 383755040..26dcddf31 100644 --- a/composer.json +++ b/composer.json @@ -34,6 +34,9 @@ "tests/Drivers/BaseDriverTestCase.php" ] }, + "conflict": { + "mnapoli/silly": ">=1.8.1 <1.8.3" + }, "require": { "php": "^7.1|^8.0", "illuminate/collections": "^8.0|^9.0|^10.0", From f9ee253db3eef9f4ce7b26d1e1963446b7442f5b Mon Sep 17 00:00:00 2001 From: Dries Vints Date: Wed, 26 Jul 2023 09:58:09 +0200 Subject: [PATCH 56/68] Update tests/CliTest.php --- tests/CliTest.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/CliTest.php b/tests/CliTest.php index 52d4abdda..c34630f09 100644 --- a/tests/CliTest.php +++ b/tests/CliTest.php @@ -259,17 +259,17 @@ public function test_link_command_with_isolate_flag_isolates() { [$app, $tester] = $this->appAndTester(); - $cwd = getcwd(); + $cwd = getcwd(); $name = 'tighten'; $host = $name.'.test'; $customPhpVersion = '82'; - $phpRcVersion = '8.2'; - $fullPhpVersion = 'php@8.2'; + $phpRcVersion = '8.2'; + $fullPhpVersion = 'php@8.2'; - $brewMock = Mockery::mock(Brew::class); + $brewMock = Mockery::mock(Brew::class); $nginxMock = Mockery::mock(Nginx::class); - $siteMock = Mockery::mock(RealSite::class); + $siteMock = Mockery::mock(RealSite::class); $phpFpmMock = Mockery::mock(PhpFpm::class, [ $brewMock, From 55078675f49ebd127b39c4434dd17bb2a5b9724c Mon Sep 17 00:00:00 2001 From: Dries Vints Date: Thu, 21 Sep 2023 21:30:35 +0200 Subject: [PATCH 57/68] PHP 8.3 (#1448) * PHP 8.3 * PHP 8.3 (#1449) --------- Co-authored-by: Chris Brown --- .github/workflows/tests.yml | 2 +- cli/Valet/Brew.php | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 3f82dffdb..47540d84e 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -16,7 +16,7 @@ jobs: strategy: fail-fast: true matrix: - php: ['8.0', 8.1, 8.2] + php: ['8.0', 8.1, 8.2, 8.3] name: PHP ${{ matrix.php }} diff --git a/cli/Valet/Brew.php b/cli/Valet/Brew.php index d7e510955..121a13935 100644 --- a/cli/Valet/Brew.php +++ b/cli/Valet/Brew.php @@ -11,6 +11,7 @@ class Brew // This is the array of PHP versions that Valet will attempt to install/configure when requested const SUPPORTED_PHP_VERSIONS = [ 'php', + 'php@8.3', 'php@8.2', 'php@8.1', 'php@8.0', From 03bb9cc131ffe47d73a06bc5f821b9485f0a6550 Mon Sep 17 00:00:00 2001 From: driesvints Date: Thu, 21 Sep 2023 19:31:00 +0000 Subject: [PATCH 58/68] Fix code styling --- cli/Valet/DnsMasq.php | 2 +- cli/Valet/Drivers/Specific/ContaoValetDriver.php | 2 +- cli/app.php | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cli/Valet/DnsMasq.php b/cli/Valet/DnsMasq.php index d5e21be03..a0d74ebee 100644 --- a/cli/Valet/DnsMasq.php +++ b/cli/Valet/DnsMasq.php @@ -78,7 +78,7 @@ public function ensureUsingDnsmasqDForConfigs(): void // set primary config to look for configs in /usr/local/etc/dnsmasq.d/*.conf $contents = $this->files->get($this->dnsmasqMasterConfigFile); // ensure the line we need to use is present, and uncomment it if needed - if (false === strpos($contents, 'conf-dir='.BREW_PREFIX.'/etc/dnsmasq.d/,*.conf')) { + if (strpos($contents, 'conf-dir='.BREW_PREFIX.'/etc/dnsmasq.d/,*.conf') === false) { $contents .= PHP_EOL.'conf-dir='.BREW_PREFIX.'/etc/dnsmasq.d/,*.conf'.PHP_EOL; } $contents = str_replace('#conf-dir='.BREW_PREFIX.'/etc/dnsmasq.d/,*.conf', 'conf-dir='.BREW_PREFIX.'/etc/dnsmasq.d/,*.conf', $contents); diff --git a/cli/Valet/Drivers/Specific/ContaoValetDriver.php b/cli/Valet/Drivers/Specific/ContaoValetDriver.php index 293e62aa3..6649b1b22 100644 --- a/cli/Valet/Drivers/Specific/ContaoValetDriver.php +++ b/cli/Valet/Drivers/Specific/ContaoValetDriver.php @@ -35,7 +35,7 @@ public function frontControllerPath(string $sitePath, string $siteName, string $ return $sitePath.'/web/install.php'; } - if (0 === strncmp($uri, '/app_dev.php', 12)) { + if (strncmp($uri, '/app_dev.php', 12) === 0) { $_SERVER['SCRIPT_NAME'] = '/app_dev.php'; $_SERVER['SCRIPT_FILENAME'] = $sitePath.'/app_dev.php'; diff --git a/cli/app.php b/cli/app.php index c5edfe5af..bf1cbd82a 100644 --- a/cli/app.php +++ b/cli/app.php @@ -117,7 +117,7 @@ function (ConsoleCommandEvent $event) { false ); - if (false === $helper->ask($input, $output, $question)) { + if ($helper->ask($input, $output, $question) === false) { return warning('No new Valet tld was set.'); } @@ -409,7 +409,7 @@ function (ConsoleCommandEvent $event) { $helper = $this->getHelperSet()->get('question'); $question = new ConfirmationQuestion('Would you like to install Expose now? [y/N] ', false); - if (false === $helper->ask($input, $output, $question)) { + if ($helper->ask($input, $output, $question) === false) { info('Proceeding without installing Expose.'); return; @@ -425,7 +425,7 @@ function (ConsoleCommandEvent $event) { $helper = $this->getHelperSet()->get('question'); $question = new ConfirmationQuestion('Would you like to install ngrok via Homebrew now? [y/N] ', false); - if (false === $helper->ask($input, $output, $question)) { + if ($helper->ask($input, $output, $question) === false) { info('Proceeding without installing ngrok.'); return; @@ -540,7 +540,7 @@ function (ConsoleCommandEvent $event) { $helper = $this->getHelperSet()->get('question'); $question = new ConfirmationQuestion('Are you sure you want to proceed? [y/N]', false); - if (false === $helper->ask($input, $output, $question)) { + if ($helper->ask($input, $output, $question) === false) { return warning('Uninstall aborted.'); } From a48540d3b4acd39df06b5bd83a9d6f09c1fcbcbe Mon Sep 17 00:00:00 2001 From: mattstauffer Date: Mon, 25 Sep 2023 16:55:28 +0000 Subject: [PATCH 59/68] Fix code styling --- tests/CliTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/CliTest.php b/tests/CliTest.php index c34630f09..374e8fbad 100644 --- a/tests/CliTest.php +++ b/tests/CliTest.php @@ -10,10 +10,10 @@ use Valet\Nginx; use Valet\Ngrok; use Valet\PhpFpm; -use function Valet\resolve; use Valet\Site as RealSite; use Valet\Valet; +use function Valet\resolve; use function Valet\swap; /** From 15185fcabb8ae7c0d002e40e87d01b11afb386de Mon Sep 17 00:00:00 2001 From: Dries Vints Date: Tue, 26 Sep 2023 18:38:05 +0200 Subject: [PATCH 60/68] version --- cli/app.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/app.php b/cli/app.php index 88d20bf12..98252b119 100644 --- a/cli/app.php +++ b/cli/app.php @@ -33,7 +33,7 @@ */ Container::setInstance(new Container); -$version = '4.3.0'; +$version = '4.4.0'; $app = new Application('Laravel Valet', $version); From 68528ba6da6c7ba0df8acc2a46231174ec10a833 Mon Sep 17 00:00:00 2001 From: driesvints Date: Tue, 26 Sep 2023 16:38:46 +0000 Subject: [PATCH 61/68] Update CHANGELOG --- CHANGELOG.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 28aa5ad2f..d4f5e5d72 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,12 @@ # Release Notes -## [Unreleased](https://github.com/laravel/valet/compare/v4.3.0...master) +## [Unreleased](https://github.com/laravel/valet/compare/v4.4.0...master) + +## [v4.4.0](https://github.com/laravel/valet/compare/v4.3.0...v4.4.0) - 2023-09-26 + +- Allow LaravelValetDriver to serve other /public/*.php files by [@drbyte](https://github.com/drbyte) in https://github.com/laravel/valet/pull/1439 +- Support static caching in Statamic by [@jasonvarga](https://github.com/jasonvarga) in https://github.com/laravel/valet/pull/1440 +- Fix link command's `--isolate` argument with custom name by [@mcaskill](https://github.com/mcaskill) in https://github.com/laravel/valet/pull/1428 ## [v4.3.0](https://github.com/laravel/valet/compare/v4.1.4...v4.3.0) - 2023-09-05 From 108bbf75b08c2ec8adb699cdcb8cc2cdc64b2d0c Mon Sep 17 00:00:00 2001 From: Mischa Braam <19824986+mischabraam@users.noreply.github.com> Date: Thu, 28 Sep 2023 16:24:05 +0200 Subject: [PATCH 62/68] Fix magento2 driver (#1420) + simplify, let mode determine by Magento env config --- .../Drivers/Specific/Magento2ValetDriver.php | 118 ++---------------- 1 file changed, 13 insertions(+), 105 deletions(-) diff --git a/cli/Valet/Drivers/Specific/Magento2ValetDriver.php b/cli/Valet/Drivers/Specific/Magento2ValetDriver.php index ad25b67ab..3bf799ae8 100644 --- a/cli/Valet/Drivers/Specific/Magento2ValetDriver.php +++ b/cli/Valet/Drivers/Specific/Magento2ValetDriver.php @@ -7,16 +7,7 @@ class Magento2ValetDriver extends ValetDriver { /** - * Holds the MAGE_MODE from app/etc/config.php or $ENV. - * - * Can't be correctly typed yet because PHP 7.3. - * - * @param string|null - */ - private $mageMode = null; - - /** - * Determine if the driver serves the request. + * @inheritdoc */ public function serves(string $sitePath, string $siteName, string $uri): bool { @@ -24,44 +15,24 @@ public function serves(string $sitePath, string $siteName, string $uri): bool } /** - * Determine if the incoming request is for a static file. + * @inheritdoc */ public function isStaticFile(string $sitePath, string $siteName, string $uri)/*: string|false */ { - $this->checkMageMode($sitePath); - - $uri = $this->handleForVersions($uri); - $route = parse_url(substr($uri, 1))['path']; - - $pub = ''; - if ($this->mageMode === 'developer') { - $pub = 'pub/'; - } - - if (! $this->isPubDirectory($sitePath, $route, $pub)) { - return false; - } - - $magentoPackagePubDir = $sitePath; - if ($this->mageMode !== 'developer') { - $magentoPackagePubDir .= '/pub'; - } - - $file = $magentoPackagePubDir.'/'.$route; + $uri = preg_replace('/^\/static(\/version[\d]+)/', '/static', $uri); - if (file_exists($file)) { - return $magentoPackagePubDir.$uri; + if (file_exists($staticFilePath = $sitePath . '/pub' . $uri)) { + return $staticFilePath; } - if (strpos($route, $pub.'static/') === 0) { - $route = preg_replace('#'.$pub.'static/#', '', $route, 1); - $_GET['resource'] = $route; - include $magentoPackagePubDir.'/'.$pub.'static.php'; + if (strpos($uri, '/static/') === 0) { + $_GET['resource'] = preg_replace('#static/#', '', $uri, 1); + include($sitePath . '/pub/static.php'); exit; } - if (strpos($route, $pub.'media/') === 0) { - include $magentoPackagePubDir.'/'.$pub.'get.php'; + if (strpos($uri, '/media/') === 0) { + include($sitePath . '/pub/get.php'); exit; } @@ -69,75 +40,12 @@ public function isStaticFile(string $sitePath, string $siteName, string $uri)/*: } /** - * Rewrite URLs that look like "versions12345/" to remove - * the versions12345/ part. - */ - private function handleForVersions($route): string - { - return preg_replace('/version\d*\//', '', $route); - } - - /** - * Determine the current MAGE_MODE. - */ - private function checkMageMode($sitePath): void - { - if ($this->mageMode !== null) { - // We have already figure out mode, no need to check it again - return; - } - - if (! file_exists($sitePath.'/index.php')) { - $this->mageMode = 'production'; // Can't use developer mode without index.php in project root - - return; - } - - $mageConfig = []; - - if (file_exists($sitePath.'/app/etc/env.php')) { - $mageConfig = require $sitePath.'/app/etc/env.php'; - } - - if (array_key_exists('MAGE_MODE', $mageConfig)) { - $this->mageMode = $mageConfig['MAGE_MODE']; - } - } - - /** - * Checks to see if route is referencing any directory inside pub. This is a dynamic check so that if any new - * directories are added to pub this driver will not need to be updated. - */ - private function isPubDirectory($sitePath, $route, $pub = ''): bool - { - $sitePath .= '/pub/'; - $dirs = glob($sitePath.'*', GLOB_ONLYDIR); - - $dirs = str_replace($sitePath, '', $dirs); - - foreach ($dirs as $dir) { - if (strpos($route, $pub.$dir.'/') === 0) { - return true; - } - } - - return false; - } - - /** - * Get the fully resolved path to the application's front controller. + * @inheritdoc */ public function frontControllerPath(string $sitePath, string $siteName, string $uri): ?string { - $this->checkMageMode($sitePath); - - if ($this->mageMode === 'developer') { - $_SERVER['DOCUMENT_ROOT'] = $sitePath; - - return $sitePath.'/index.php'; - } - - $_SERVER['DOCUMENT_ROOT'] = $sitePath.'/pub'; + $_SERVER['SERVER_NAME'] = $_SERVER['HTTP_HOST']; + $_SERVER['DOCUMENT_ROOT'] = $sitePath; return $sitePath.'/pub/index.php'; } From 0fef72b64b96d76141c887ce4f002551a4ba3858 Mon Sep 17 00:00:00 2001 From: driesvints Date: Thu, 28 Sep 2023 14:24:39 +0000 Subject: [PATCH 63/68] Fix code styling --- cli/Valet/Drivers/Specific/Magento2ValetDriver.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/cli/Valet/Drivers/Specific/Magento2ValetDriver.php b/cli/Valet/Drivers/Specific/Magento2ValetDriver.php index 3bf799ae8..c6c7d4314 100644 --- a/cli/Valet/Drivers/Specific/Magento2ValetDriver.php +++ b/cli/Valet/Drivers/Specific/Magento2ValetDriver.php @@ -7,7 +7,7 @@ class Magento2ValetDriver extends ValetDriver { /** - * @inheritdoc + * {@inheritdoc} */ public function serves(string $sitePath, string $siteName, string $uri): bool { @@ -15,24 +15,24 @@ public function serves(string $sitePath, string $siteName, string $uri): bool } /** - * @inheritdoc + * {@inheritdoc} */ public function isStaticFile(string $sitePath, string $siteName, string $uri)/*: string|false */ { $uri = preg_replace('/^\/static(\/version[\d]+)/', '/static', $uri); - if (file_exists($staticFilePath = $sitePath . '/pub' . $uri)) { + if (file_exists($staticFilePath = $sitePath.'/pub'.$uri)) { return $staticFilePath; } if (strpos($uri, '/static/') === 0) { $_GET['resource'] = preg_replace('#static/#', '', $uri, 1); - include($sitePath . '/pub/static.php'); + include $sitePath.'/pub/static.php'; exit; } if (strpos($uri, '/media/') === 0) { - include($sitePath . '/pub/get.php'); + include $sitePath.'/pub/get.php'; exit; } @@ -40,11 +40,11 @@ public function isStaticFile(string $sitePath, string $siteName, string $uri)/*: } /** - * @inheritdoc + * {@inheritdoc} */ public function frontControllerPath(string $sitePath, string $siteName, string $uri): ?string { - $_SERVER['SERVER_NAME'] = $_SERVER['HTTP_HOST']; + $_SERVER['SERVER_NAME'] = $_SERVER['HTTP_HOST']; $_SERVER['DOCUMENT_ROOT'] = $sitePath; return $sitePath.'/pub/index.php'; From 15e444afc2753f5a65732d59860b182968000bad Mon Sep 17 00:00:00 2001 From: Dries Vints Date: Tue, 3 Oct 2023 16:51:46 +0200 Subject: [PATCH 64/68] version --- cli/app.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/app.php b/cli/app.php index 98252b119..a13940751 100644 --- a/cli/app.php +++ b/cli/app.php @@ -33,7 +33,7 @@ */ Container::setInstance(new Container); -$version = '4.4.0'; +$version = '4.4.1'; $app = new Application('Laravel Valet', $version); From 66539bd2cecb80123284e114c0db08ff1cfeb1ad Mon Sep 17 00:00:00 2001 From: driesvints Date: Tue, 3 Oct 2023 14:52:37 +0000 Subject: [PATCH 65/68] Update CHANGELOG --- CHANGELOG.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d4f5e5d72..7b466adcf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,10 @@ # Release Notes -## [Unreleased](https://github.com/laravel/valet/compare/v4.4.0...master) +## [Unreleased](https://github.com/laravel/valet/compare/v4.4.1...master) + +## [v4.4.1](https://github.com/laravel/valet/compare/v4.4.0...v4.4.1) - 2023-10-03 + +- Fix magento2 driver by [@mischabraam](https://github.com/mischabraam) in https://github.com/laravel/valet/pull/1420 ## [v4.4.0](https://github.com/laravel/valet/compare/v4.3.0...v4.4.0) - 2023-09-26 From 060c8d5bb26a2aaa911800fabe727d9280eefd04 Mon Sep 17 00:00:00 2001 From: Dries Vints Date: Tue, 10 Oct 2023 17:42:20 +0200 Subject: [PATCH 66/68] version --- cli/app.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/app.php b/cli/app.php index a13940751..61eeef510 100644 --- a/cli/app.php +++ b/cli/app.php @@ -33,7 +33,7 @@ */ Container::setInstance(new Container); -$version = '4.4.1'; +$version = '4.5.0'; $app = new Application('Laravel Valet', $version); From 344fd515da5ea13cf3779bc71aa0a5441bacfff1 Mon Sep 17 00:00:00 2001 From: driesvints Date: Tue, 10 Oct 2023 15:43:03 +0000 Subject: [PATCH 67/68] Update CHANGELOG --- CHANGELOG.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7b466adcf..3f309fb4f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,10 @@ # Release Notes -## [Unreleased](https://github.com/laravel/valet/compare/v4.4.1...master) +## [Unreleased](https://github.com/laravel/valet/compare/v4.5.0...master) + +## [v4.5.0](https://github.com/laravel/valet/compare/v4.4.1...v4.5.0) - 2023-10-10 + +- Add support for proxying multiple domains at once by [@RobertBoes](https://github.com/RobertBoes) in https://github.com/laravel/valet/pull/1437 ## [v4.4.1](https://github.com/laravel/valet/compare/v4.4.0...v4.4.1) - 2023-10-03 From c4fb099eeab3bc557844634e1a91a8b55f413d9e Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Tue, 17 Oct 2023 14:37:27 +0100 Subject: [PATCH 68/68] Uses `actions/checkout@v4` --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 47540d84e..454e7ed34 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -22,7 +22,7 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Setup PHP uses: shivammathur/setup-php@v2