mirror of
https://github.com/laravel/valet.git
synced 2026-02-07 09:10:03 +01:00
Merge branch 'master' into master
This commit is contained in:
@@ -129,7 +129,8 @@ function restartService($services)
|
||||
$services = is_array($services) ? $services : func_get_args();
|
||||
|
||||
foreach ($services as $service) {
|
||||
$this->cli->quietly('sudo brew services restart '.$service);
|
||||
$this->cli->quietly('sudo brew services stop '.$service);
|
||||
$this->cli->quietly('sudo brew services start '.$service);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -122,7 +122,7 @@ function rewriteSecureNginxFiles()
|
||||
*/
|
||||
function restart()
|
||||
{
|
||||
$this->cli->quietly('sudo brew services restart '. $this->brew->nginxServiceName());
|
||||
$this->brew->restartService($this->brew->nginxServiceName());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -75,8 +75,6 @@ function updateConfiguration()
|
||||
*/
|
||||
function restart()
|
||||
{
|
||||
$this->stop();
|
||||
|
||||
$this->brew->restartLinkedPhp();
|
||||
}
|
||||
|
||||
|
||||
@@ -151,12 +151,15 @@ function createCertificate($url)
|
||||
$keyPath = $this->certificatesPath().'/'.$url.'.key';
|
||||
$csrPath = $this->certificatesPath().'/'.$url.'.csr';
|
||||
$crtPath = $this->certificatesPath().'/'.$url.'.crt';
|
||||
$confPath = $this->certificatesPath().'/'.$url.'.conf';
|
||||
|
||||
$this->buildCertificateConf($confPath, $url);
|
||||
$this->createPrivateKey($keyPath);
|
||||
$this->createSigningRequest($url, $keyPath, $csrPath);
|
||||
$this->createSigningRequest($url, $keyPath, $csrPath, $confPath);
|
||||
|
||||
$this->cli->runAsUser(sprintf(
|
||||
'openssl x509 -req -days 365 -in %s -signkey %s -out %s', $csrPath, $keyPath, $crtPath
|
||||
'openssl x509 -req -days 365 -in %s -signkey %s -out %s -extensions v3_req -extfile %s',
|
||||
$csrPath, $keyPath, $crtPath, $confPath
|
||||
));
|
||||
|
||||
$this->trustCertificate($crtPath);
|
||||
@@ -179,11 +182,11 @@ function createPrivateKey($keyPath)
|
||||
* @param string $keyPath
|
||||
* @return void
|
||||
*/
|
||||
function createSigningRequest($url, $keyPath, $csrPath)
|
||||
function createSigningRequest($url, $keyPath, $csrPath, $confPath)
|
||||
{
|
||||
$this->cli->runAsUser(sprintf(
|
||||
'openssl req -new -subj "/C=/ST=/O=/localityName=/commonName=%s/organizationalUnitName=/emailAddress=/" -key %s -out %s -passin pass:',
|
||||
$url, $keyPath, $csrPath
|
||||
'openssl req -new -key %s -out %s -subj "/C=/ST=/O=/localityName=/commonName=*.%s/organizationalUnitName=/emailAddress=/" -config %s -passin pass:',
|
||||
$keyPath, $csrPath, $url, $confPath
|
||||
));
|
||||
}
|
||||
|
||||
@@ -200,6 +203,18 @@ function trustCertificate($crtPath)
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the SSL config for the given URL.
|
||||
*
|
||||
* @param string $url
|
||||
* @return string
|
||||
*/
|
||||
function buildCertificateConf($path, $url)
|
||||
{
|
||||
$config = str_replace('VALET_DOMAIN', $url, $this->files->get(__DIR__.'/../stubs/openssl.conf'));
|
||||
$this->files->putAsUser($path, $config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the TLS secured Nginx server for the given URL.
|
||||
*
|
||||
@@ -228,6 +243,7 @@ function unsecure($url)
|
||||
if ($this->files->exists($this->certificatesPath().'/'.$url.'.crt')) {
|
||||
$this->files->unlink(VALET_HOME_PATH.'/Nginx/'.$url);
|
||||
|
||||
$this->files->unlink($this->certificatesPath().'/'.$url.'.conf');
|
||||
$this->files->unlink($this->certificatesPath().'/'.$url.'.key');
|
||||
$this->files->unlink($this->certificatesPath().'/'.$url.'.csr');
|
||||
$this->files->unlink($this->certificatesPath().'/'.$url.'.crt');
|
||||
|
||||
25
cli/stubs/openssl.conf
Normal file
25
cli/stubs/openssl.conf
Normal file
@@ -0,0 +1,25 @@
|
||||
[req]
|
||||
distinguished_name = req_distinguished_name
|
||||
req_extensions = v3_req
|
||||
|
||||
[req_distinguished_name]
|
||||
countryName = Country Name (2 letter code)
|
||||
countryName_default = US
|
||||
stateOrProvinceName = State or Province Name (full name)
|
||||
stateOrProvinceName_default = MN
|
||||
localityName = Locality Name (eg, city)
|
||||
localityName_default = Minneapolis
|
||||
organizationalUnitName = Organizational Unit Name (eg, section)
|
||||
organizationalUnitName_default = Domain Control Validated
|
||||
commonName = Internet Widgits Ltd
|
||||
commonName_max = 64
|
||||
|
||||
[ v3_req ]
|
||||
# Extensions to add to a certificate request
|
||||
basicConstraints = CA:FALSE
|
||||
keyUsage = nonRepudiation, digitalSignature, keyEncipherment
|
||||
subjectAltName = @alt_names
|
||||
|
||||
[alt_names]
|
||||
DNS.1 = VALET_DOMAIN
|
||||
DNS.2 = *.VALET_DOMAIN
|
||||
@@ -1,12 +1,12 @@
|
||||
server {
|
||||
listen 80;
|
||||
server_name VALET_SITE;
|
||||
server_name VALET_SITE www.VALET_SITE *.VALET_SITE;
|
||||
return 301 https://$host$request_uri;
|
||||
}
|
||||
|
||||
server {
|
||||
listen 443 ssl http2;
|
||||
server_name VALET_SITE;
|
||||
server_name VALET_SITE www.VALET_SITE *.VALET_SITE;
|
||||
root /;
|
||||
charset utf-8;
|
||||
|
||||
|
||||
@@ -172,13 +172,13 @@
|
||||
})->descriptions('Get all of the paths registered with Valet');
|
||||
|
||||
/**
|
||||
* Open the current directory in the browser.
|
||||
* Open the current or given directory in the browser.
|
||||
*/
|
||||
$app->command('open', function () {
|
||||
$url = "http://".Site::host(getcwd()).'.'.Configuration::read()['domain'].'/';
|
||||
$app->command('open [domain]', function ($domain = null) {
|
||||
$url = "http://".($domain ?: Site::host(getcwd())).'.'.Configuration::read()['domain'];
|
||||
|
||||
passthru("open ".escapeshellarg($url));
|
||||
})->descriptions('Open the site for the current directory in your browser');
|
||||
})->descriptions('Open the site for the current (or specified) directory in your browser');
|
||||
|
||||
/**
|
||||
* Generate a publicly accessible URL for your project.
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
},
|
||||
"require-dev": {
|
||||
"mockery/mockery": "0.9.*",
|
||||
"phpunit/phpunit": ">=4.8.24"
|
||||
"phpunit/phpunit": "~5.7"
|
||||
},
|
||||
"bin": [
|
||||
"valet"
|
||||
|
||||
@@ -65,9 +65,11 @@ function valet_support_xip_io($domain)
|
||||
$valetSitePath = null;
|
||||
|
||||
foreach ($valetConfig['paths'] as $path) {
|
||||
if (is_dir($path.'/'.$siteName)) {
|
||||
$valetSitePath = $path.'/'.$siteName;
|
||||
|
||||
$domain = ($pos = strrpos($siteName, '.')) !== false
|
||||
? substr($siteName, $pos+1)
|
||||
: null;
|
||||
if (is_dir($path.'/'.$siteName) || is_dir($path.'/'.$domain)) {
|
||||
$valetSitePath = $path.'/'.($domain ?: $siteName);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,7 +99,8 @@ public function test_tap_taps_the_given_homebrew_repository()
|
||||
public function test_restart_restarts_the_service_using_homebrew_services()
|
||||
{
|
||||
$cli = Mockery::mock(CommandLine::class);
|
||||
$cli->shouldReceive('quietly')->once()->with('sudo brew services restart dnsmasq');
|
||||
$cli->shouldReceive('quietly')->once()->with('sudo brew services stop dnsmasq');
|
||||
$cli->shouldReceive('quietly')->once()->with('sudo brew services start dnsmasq');
|
||||
swap(CommandLine::class, $cli);
|
||||
resolve(Brew::class)->restartService('dnsmasq');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user