1
0
mirror of https://github.com/laravel/valet.git synced 2026-02-06 16:50:09 +01:00

fix open for symlinks

This commit is contained in:
Taylor Otwell
2016-05-12 21:24:28 -05:00
parent 399de8bfff
commit 62ba72a77a
2 changed files with 26 additions and 11 deletions

View File

@@ -22,6 +22,23 @@ function __construct(Configuration $config, CommandLine $cli, Filesystem $files)
$this->config = $config;
}
/**
* Get the real hostname for the given path, checking links.
*
* @param string $path
* @return string|null
*/
function hostForDirectory($path)
{
foreach ($this->files->scandir($this->sitesPath()) as $link) {
if ($resolved = realpath($this->sitesPath().'/'.$link) == $path) {
return $link;
}
}
return basename($path);
}
/**
* Link the current working directory with the given name.
*

View File

@@ -154,6 +154,15 @@
}
})->descriptions('Get all of the paths registered with Valet');
/**
* Open the current directory in the browser.
*/
$app->command('open', function () {
$url = "http://".Site::hostForDirectory(getcwd()).'.'.Configuration::read()['domain'].'/';
passthru("open ".escapeshellarg($url));
});
/**
* Echo the currently tunneled URL.
*/
@@ -221,17 +230,6 @@
include $extension;
}
/**
* Open the current url.
*/
$app->command('open', function () {
$url = "http://".basename(getcwd()).'.'.Configuration::read()['domain'].'/';
passthru("open ".escapeshellarg($url));
info('The url ['.$url.'] has been openend.');
});
/**
* Run the application.
*/