Skip to content

Commit

Permalink
Gets the default "tld" on install. (#336)
Browse files Browse the repository at this point in the history
* Gets the default "tld" on install.

* Update NewCommand.php

---------

Co-authored-by: Taylor Otwell <taylor@laravel.com>
  • Loading branch information
xiCO2k and taylorotwell authored May 5, 2024
1 parent ad66a9a commit 620f1b3
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/NewCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down

0 comments on commit 620f1b3

Please sign in to comment.