Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improves output if Herd or Valet are installed. #335

Merged
merged 8 commits into from
May 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 31 additions & 3 deletions src/NewCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -212,11 +212,16 @@ protected function execute(InputInterface $input, OutputInterface $output): int
}

$output->writeln(" <bg=blue;fg=white> INFO </> Application ready in <options=bold>[{$name}]</>. You can start your local development using:".PHP_EOL);

$output->writeln('<fg=gray>➜</> <options=bold>cd '.$name.'</>');
$output->writeln('<fg=gray>➜</> <options=bold>php artisan serve</>');
$output->writeln('');

if ($this->isParked($directory)) {
$url = $this->generateAppUrl($name);
$output->writeln('<fg=gray>➜</> Open: <options=bold;href='.$url.'>'.$url.'</>');
} else {
$output->writeln('<fg=gray>➜</> <options=bold>php artisan serve</>');
}

$output->writeln('');
$output->writeln(' New to Laravel? Check out our <href=https://bootcamp.laravel.com>bootcamp</> and <href=https://laravel.com/docs/installation#next-steps>documentation</>. <options=bold>Build something amazing!</>');
$output->writeln('');
}
Expand Down Expand Up @@ -756,6 +761,29 @@ protected function canResolveHostname($hostname)
return gethostbyname($hostname.'.') !== $hostname.'.';
}

/**
* Determine if the given directory is parked using Herd or Valet.
*
* @param string $directory
* @return bool
*/
protected function isParked(string $directory)
{
foreach (['herd', 'valet'] as $tool) {
$process = new Process([$tool, 'paths']);

$process->run();

if ($process->isSuccessful()) {
$output = json_decode(trim($process->getOutput()));

return in_array(dirname($directory), $output);
}
}

return false;
}

/**
* Get the version that should be downloaded.
*
Expand Down