Skip to content

Commit f7d4ed0

Browse files
committed
use localhost 8000 if not using herd or valet
1 parent d2a438e commit f7d4ed0

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/NewCommand.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
260260
if ($name !== '.') {
261261
$this->replaceInFile(
262262
'APP_URL=http://localhost',
263-
'APP_URL='.$this->generateAppUrl($name),
263+
'APP_URL='.$this->generateAppUrl($name, $directory),
264264
$directory.'/.env'
265265
);
266266

@@ -323,7 +323,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
323323
}
324324

325325
if ($this->isParkedOnHerdOrValet($directory)) {
326-
$url = $this->generateAppUrl($name);
326+
$url = $this->generateAppUrl($name, $directory);
327327
$output->writeln('<fg=gray>➜</> Open: <options=bold;href='.$url.'>'.$url.'</>');
328328
} else {
329329
$output->writeln('<fg=gray>➜</> <options=bold>composer run dev</>');
@@ -740,10 +740,15 @@ protected function verifyApplicationDoesntExist($directory)
740740
* Generate a valid APP_URL for the given application name.
741741
*
742742
* @param string $name
743+
* @param string $directory
743744
* @return string
744745
*/
745-
protected function generateAppUrl($name)
746+
protected function generateAppUrl($name, $directory)
746747
{
748+
if (! $this->isParkedOnHerdOrValet($directory)) {
749+
return 'http://localhost:8000';
750+
}
751+
747752
$hostname = mb_strtolower($name).'.'.$this->getTld();
748753

749754
return $this->canResolveHostname($hostname) ? 'http://'.$hostname : 'http://localhost';

0 commit comments

Comments
 (0)