mirror of
https://github.com/laravel/valet.git
synced 2026-02-06 08:40:09 +01:00
fix open for symlinks
This commit is contained in:
@@ -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.
|
||||
*
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user