diff --git a/src/NewCommand.php b/src/NewCommand.php index 497f5c2..a927e85 100644 --- a/src/NewCommand.php +++ b/src/NewCommand.php @@ -212,11 +212,16 @@ protected function execute(InputInterface $input, OutputInterface $output): int } $output->writeln(" INFO Application ready in [{$name}]. You can start your local development using:".PHP_EOL); - $output->writeln('cd '.$name.''); - $output->writeln('php artisan serve'); - $output->writeln(''); + if ($this->isParked($directory)) { + $url = $this->generateAppUrl($name); + $output->writeln('➜ Open: '.$url.''); + } else { + $output->writeln('php artisan serve'); + } + + $output->writeln(''); $output->writeln(' New to Laravel? Check out our bootcamp and documentation. Build something amazing!'); $output->writeln(''); } @@ -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. *