From 620f1b32e71a7f6bb325da381ca613f626f13160 Mon Sep 17 00:00:00 2001 From: Francisco Madeira Date: Sun, 5 May 2024 16:44:03 +0100 Subject: [PATCH] Gets the default "tld" on install. (#336) * Gets the default "tld" on install. * Update NewCommand.php --------- Co-authored-by: Taylor Otwell --- src/NewCommand.php | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/NewCommand.php b/src/NewCommand.php index a927e85..032b0ee 100644 --- a/src/NewCommand.php +++ b/src/NewCommand.php @@ -745,11 +745,31 @@ protected function verifyApplicationDoesntExist($directory) */ protected function generateAppUrl($name) { - $hostname = mb_strtolower($name).'.test'; + $hostname = mb_strtolower($name).'.'.$this->getTld(); return $this->canResolveHostname($hostname) ? 'http://'.$hostname : 'http://localhost'; } + /** + * Get the TLD for the application. + * + * @return string + */ + protected function getTld() + { + foreach (['herd', 'valet'] as $tool) { + $process = new Process([$tool, 'tld']); + + $process->run(); + + if ($process->isSuccessful()) { + return trim($process->getOutput()); + } + } + + return 'test'; + } + /** * Determine whether the given hostname is resolvable. *