mirror of
https://github.com/laravel/valet.git
synced 2026-02-05 00:20:08 +01:00
Merge branch 'master' into tld-alias-for-domain-command
This commit is contained in:
@@ -4,6 +4,7 @@ php:
|
|||||||
- 5.6
|
- 5.6
|
||||||
- 7.0
|
- 7.0
|
||||||
- 7.1
|
- 7.1
|
||||||
|
- 7.2
|
||||||
- nightly
|
- nightly
|
||||||
|
|
||||||
env:
|
env:
|
||||||
|
|||||||
@@ -7,6 +7,9 @@
|
|||||||
|
|
||||||
class Brew
|
class Brew
|
||||||
{
|
{
|
||||||
|
const SUPPORTED_PHP_VERSIONS = ['php', 'php@7.2', 'php@7.1', 'php@7.0', 'php@5.6', 'php72', 'php71', 'php70', 'php56'];
|
||||||
|
const LATEST_PHP_VERSION = 'php@7.2';
|
||||||
|
|
||||||
var $cli, $files;
|
var $cli, $files;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -52,7 +55,7 @@ function hasInstalledPhp()
|
|||||||
*/
|
*/
|
||||||
function supportedPhpVersions()
|
function supportedPhpVersions()
|
||||||
{
|
{
|
||||||
return collect(['php72', 'php71', 'php70', 'php56']);
|
return collect(static::SUPPORTED_PHP_VERSIONS);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -182,7 +185,9 @@ function linkedPhp()
|
|||||||
$resolvedPath = $this->files->readLink('/usr/local/bin/php');
|
$resolvedPath = $this->files->readLink('/usr/local/bin/php');
|
||||||
|
|
||||||
return $this->supportedPhpVersions()->first(function ($version) use ($resolvedPath) {
|
return $this->supportedPhpVersions()->first(function ($version) use ($resolvedPath) {
|
||||||
return strpos($resolvedPath, $version) !== false;
|
$resolvedPathNormalized= preg_replace('/([@|\.])/', '', $resolvedPath);
|
||||||
|
$versionNormalized = preg_replace('/([@|\.])/', '', $version);
|
||||||
|
return strpos($resolvedPathNormalized, "/$versionNormalized/") !== false;
|
||||||
}, function () {
|
}, function () {
|
||||||
throw new DomainException("Unable to determine linked PHP.");
|
throw new DomainException("Unable to determine linked PHP.");
|
||||||
});
|
});
|
||||||
@@ -197,4 +202,17 @@ function restartLinkedPhp()
|
|||||||
{
|
{
|
||||||
$this->restartService($this->linkedPhp());
|
$this->restartService($this->linkedPhp());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create the "sudoers.d" entry for running Brew.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function createSudoersEntry()
|
||||||
|
{
|
||||||
|
$this->files->ensureDirExists('/etc/sudoers.d');
|
||||||
|
|
||||||
|
$this->files->put('/etc/sudoers.d/brew', 'Cmnd_Alias BREW = /usr/local/bin/brew *
|
||||||
|
%admin ALL=(root) NOPASSWD: BREW'.PHP_EOL);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -95,7 +95,10 @@ function restart()
|
|||||||
*/
|
*/
|
||||||
function stop()
|
function stop()
|
||||||
{
|
{
|
||||||
$this->brew->stopService('php56', 'php70', 'php71', 'php72');
|
call_user_func_array(
|
||||||
|
[$this->brew, 'stopService'],
|
||||||
|
Brew::SUPPORTED_PHP_VERSIONS
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -105,13 +108,16 @@ function stop()
|
|||||||
*/
|
*/
|
||||||
function fpmConfigPath()
|
function fpmConfigPath()
|
||||||
{
|
{
|
||||||
$confLookup = [
|
$version = $this->brew->linkedPhp();
|
||||||
'php72' => '/usr/local/etc/php/7.2/php-fpm.d/www.conf',
|
|
||||||
'php71' => '/usr/local/etc/php/7.1/php-fpm.d/www.conf',
|
|
||||||
'php70' => '/usr/local/etc/php/7.0/php-fpm.d/www.conf',
|
|
||||||
'php56' => '/usr/local/etc/php/5.6/php-fpm.conf',
|
|
||||||
];
|
|
||||||
|
|
||||||
return $confLookup[$this->brew->linkedPhp()];
|
$versionNormalized = preg_replace(
|
||||||
|
'/php@?(\d)\.?(\d)/',
|
||||||
|
'$1.$2',
|
||||||
|
$version === 'php' ? Brew::LATEST_PHP_VERSION : $version
|
||||||
|
);
|
||||||
|
|
||||||
|
return $versionNormalized === '5.6'
|
||||||
|
? '/usr/local/etc/php/5.6/php-fpm.conf'
|
||||||
|
: "/usr/local/etc/php/${versionNormalized}/php-fpm.d/www.conf";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,7 +64,8 @@ function link($target, $link)
|
|||||||
*
|
*
|
||||||
* @return \Illuminate\Support\Collection
|
* @return \Illuminate\Support\Collection
|
||||||
*/
|
*/
|
||||||
function links() {
|
function links()
|
||||||
|
{
|
||||||
$certsPath = VALET_HOME_PATH.'/Certificates';
|
$certsPath = VALET_HOME_PATH.'/Certificates';
|
||||||
|
|
||||||
$this->files->ensureDirExists($certsPath, user());
|
$this->files->ensureDirExists($certsPath, user());
|
||||||
@@ -82,11 +83,11 @@ function links() {
|
|||||||
*/
|
*/
|
||||||
function getCertificates($path)
|
function getCertificates($path)
|
||||||
{
|
{
|
||||||
return collect($this->files->scanDir($path))->filter(function ($value, $key) {
|
return collect($this->files->scandir($path))->filter(function ($value, $key) {
|
||||||
return ends_with($value, '.crt');
|
return ends_with($value, '.crt');
|
||||||
})->map(function ($cert) {
|
})->map(function ($cert) {
|
||||||
$tld = $this->config->read()['tld'];
|
$tld = $this->config->read()['tld'];
|
||||||
return substr($cert, 0, -(strlen($tld)+5));
|
return substr($cert, 0, strripos($tld, '.', -5));
|
||||||
})->flip();
|
})->flip();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -101,7 +102,7 @@ function getLinks($path, $certs)
|
|||||||
{
|
{
|
||||||
$config = $this->config->read();
|
$config = $this->config->read();
|
||||||
|
|
||||||
return collect($this->files->scanDir($path))->mapWithKeys(function ($site) use ($path) {
|
return collect($this->files->scandir($path))->mapWithKeys(function ($site) use ($path) {
|
||||||
return [$site => $this->files->readLink($path.'/'.$site)];
|
return [$site => $this->files->readLink($path.'/'.$site)];
|
||||||
})->map(function ($path, $site) use ($certs, $config) {
|
})->map(function ($path, $site) use ($certs, $config) {
|
||||||
$secured = $certs->has($site);
|
$secured = $certs->has($site);
|
||||||
@@ -183,8 +184,12 @@ function secure($url)
|
|||||||
{
|
{
|
||||||
$this->unsecure($url);
|
$this->unsecure($url);
|
||||||
|
|
||||||
|
$this->files->ensureDirExists($this->caPath(), user());
|
||||||
|
|
||||||
$this->files->ensureDirExists($this->certificatesPath(), user());
|
$this->files->ensureDirExists($this->certificatesPath(), user());
|
||||||
|
|
||||||
|
$this->createCa();
|
||||||
|
|
||||||
$this->createCertificate($url);
|
$this->createCertificate($url);
|
||||||
|
|
||||||
$this->files->putAsUser(
|
$this->files->putAsUser(
|
||||||
@@ -192,6 +197,42 @@ function secure($url)
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If CA and root certificates are nonexistent, crete them and trust the root cert.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function createCa()
|
||||||
|
{
|
||||||
|
$caPemPath = $this->caPath().'/LaravelValetCASelfSigned.pem';
|
||||||
|
$caKeyPath = $this->caPath().'/LaravelValetCASelfSigned.key';
|
||||||
|
|
||||||
|
if ($this->files->exists($caKeyPath) && $this->files->exists($caPemPath)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$oName = 'Laravel Valet CA Self Signed Organization';
|
||||||
|
$cName = 'Laravel Valet CA Self Signed CN';
|
||||||
|
|
||||||
|
if ($this->files->exists($caKeyPath)) {
|
||||||
|
$this->files->unlink($caKeyPath);
|
||||||
|
}
|
||||||
|
if ($this->files->exists($caPemPath)) {
|
||||||
|
$this->files->unlink($caPemPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->cli->run(sprintf(
|
||||||
|
'sudo security delete-certificate -c "%s" /Library/Keychains/System.keychain',
|
||||||
|
$cName
|
||||||
|
));
|
||||||
|
|
||||||
|
$this->cli->runAsUser(sprintf(
|
||||||
|
'openssl req -new -newkey rsa:2048 -days 730 -nodes -x509 -subj "/C=/ST=/O=%s/localityName=/commonName=%s/organizationalUnitName=Developers/emailAddress=%s/" -keyout %s -out %s',
|
||||||
|
$oName, $cName, 'rootcertificate@laravel.valet', $caKeyPath, $caPemPath
|
||||||
|
));
|
||||||
|
$this->trustCa($caPemPath);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create and trust a certificate for the given URL.
|
* Create and trust a certificate for the given URL.
|
||||||
*
|
*
|
||||||
@@ -200,6 +241,9 @@ function secure($url)
|
|||||||
*/
|
*/
|
||||||
function createCertificate($url)
|
function createCertificate($url)
|
||||||
{
|
{
|
||||||
|
$caPemPath = $this->caPath().'/LaravelValetCASelfSigned.pem';
|
||||||
|
$caKeyPath = $this->caPath().'/LaravelValetCASelfSigned.key';
|
||||||
|
$caSrlPath = $this->caPath().'/LaravelValetCASelfSigned.srl';
|
||||||
$keyPath = $this->certificatesPath().'/'.$url.'.key';
|
$keyPath = $this->certificatesPath().'/'.$url.'.key';
|
||||||
$csrPath = $this->certificatesPath().'/'.$url.'.csr';
|
$csrPath = $this->certificatesPath().'/'.$url.'.csr';
|
||||||
$crtPath = $this->certificatesPath().'/'.$url.'.crt';
|
$crtPath = $this->certificatesPath().'/'.$url.'.crt';
|
||||||
@@ -209,9 +253,14 @@ function createCertificate($url)
|
|||||||
$this->createPrivateKey($keyPath);
|
$this->createPrivateKey($keyPath);
|
||||||
$this->createSigningRequest($url, $keyPath, $csrPath, $confPath);
|
$this->createSigningRequest($url, $keyPath, $csrPath, $confPath);
|
||||||
|
|
||||||
|
$caSrlParam = ' -CAcreateserial';
|
||||||
|
if ($this->files->exists($caSrlPath)) {
|
||||||
|
$caSrlParam = ' -CAserial ' . $caSrlPath;
|
||||||
|
}
|
||||||
|
|
||||||
$this->cli->runAsUser(sprintf(
|
$this->cli->runAsUser(sprintf(
|
||||||
'openssl x509 -req -sha256 -days 365 -in %s -signkey %s -out %s -extensions v3_req -extfile %s',
|
'openssl x509 -req -sha256 -days 730 -CA %s -CAkey %s%s -in %s -out %s -extensions v3_req -extfile %s',
|
||||||
$csrPath, $keyPath, $crtPath, $confPath
|
$caPemPath, $caKeyPath, $caSrlParam, $csrPath, $crtPath, $confPath
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->trustCertificate($crtPath);
|
$this->trustCertificate($crtPath);
|
||||||
@@ -237,8 +286,21 @@ function createPrivateKey($keyPath)
|
|||||||
function createSigningRequest($url, $keyPath, $csrPath, $confPath)
|
function createSigningRequest($url, $keyPath, $csrPath, $confPath)
|
||||||
{
|
{
|
||||||
$this->cli->runAsUser(sprintf(
|
$this->cli->runAsUser(sprintf(
|
||||||
'openssl req -new -key %s -out %s -subj "/C=/ST=/O=/localityName=/commonName=*.%s/organizationalUnitName=/emailAddress=/" -config %s -passin pass:',
|
'openssl req -new -key %s -out %s -subj "/C=/ST=/O=/localityName=/commonName=%s/organizationalUnitName=/emailAddress=%s%s/" -config %s',
|
||||||
$keyPath, $csrPath, $url, $confPath
|
$keyPath, $csrPath, $url, $url, '@laravel.valet', $confPath
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Trust the given root certificate file in the Mac Keychain.
|
||||||
|
*
|
||||||
|
* @param string $pemPath
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function trustCa($caPemPath)
|
||||||
|
{
|
||||||
|
$this->cli->run(sprintf(
|
||||||
|
'sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain %s', $caPemPath
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -251,7 +313,7 @@ function createSigningRequest($url, $keyPath, $csrPath, $confPath)
|
|||||||
function trustCertificate($crtPath)
|
function trustCertificate($crtPath)
|
||||||
{
|
{
|
||||||
$this->cli->run(sprintf(
|
$this->cli->run(sprintf(
|
||||||
'sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain %s', $crtPath
|
'sudo security add-trusted-cert -d -r trustAsRoot -k /Library/Keychains/System.keychain %s', $crtPath
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -299,9 +361,14 @@ function unsecure($url)
|
|||||||
$this->files->unlink($this->certificatesPath().'/'.$url.'.key');
|
$this->files->unlink($this->certificatesPath().'/'.$url.'.key');
|
||||||
$this->files->unlink($this->certificatesPath().'/'.$url.'.csr');
|
$this->files->unlink($this->certificatesPath().'/'.$url.'.csr');
|
||||||
$this->files->unlink($this->certificatesPath().'/'.$url.'.crt');
|
$this->files->unlink($this->certificatesPath().'/'.$url.'.crt');
|
||||||
|
|
||||||
$this->cli->run(sprintf('sudo security delete-certificate -c "%s" -t', $url));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->cli->run(sprintf('sudo security delete-certificate -c "%s" /Library/Keychains/System.keychain', $url));
|
||||||
|
$this->cli->run(sprintf('sudo security delete-certificate -c "*.%s" /Library/Keychains/System.keychain', $url));
|
||||||
|
$this->cli->run(sprintf(
|
||||||
|
'sudo security find-certificate -e "%s%s" -a -Z | grep SHA-1 | sudo awk \'{system("security delete-certificate -Z "$NF" /Library/Keychains/System.keychain")}\'',
|
||||||
|
$url, '@laravel.valet'
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -314,6 +381,16 @@ function sitesPath()
|
|||||||
return VALET_HOME_PATH.'/Sites';
|
return VALET_HOME_PATH.'/Sites';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the path to the Valet CA certificates.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function caPath()
|
||||||
|
{
|
||||||
|
return VALET_HOME_PATH.'/CA';
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the path to the Valet TLS certificates.
|
* Get the path to the Valet TLS certificates.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -65,4 +65,17 @@ function onLatestVersion($currentVersion)
|
|||||||
|
|
||||||
return version_compare($currentVersion, trim($response->body->tag_name, 'v'), '>=');
|
return version_compare($currentVersion, trim($response->body->tag_name, 'v'), '>=');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create the "sudoers.d" entry for running Valet.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function createSudoersEntry()
|
||||||
|
{
|
||||||
|
$this->files->ensureDirExists('/etc/sudoers.d');
|
||||||
|
|
||||||
|
$this->files->put('/etc/sudoers.d/valet', 'Cmnd_Alias VALET = /usr/local/bin/valet *
|
||||||
|
%admin ALL=(root) NOPASSWD: VALET'.PHP_EOL);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,6 +23,14 @@ public function serves($sitePath, $siteName, $uri)
|
|||||||
*/
|
*/
|
||||||
public function frontControllerDirectory($sitePath)
|
public function frontControllerDirectory($sitePath)
|
||||||
{
|
{
|
||||||
|
$dirs = ['web', 'public'];
|
||||||
|
|
||||||
|
foreach ($dirs as $dir) {
|
||||||
|
if (is_dir($sitePath.'/'.$dir)) {
|
||||||
|
return $dir;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Give up, and just return the default
|
||||||
return is_file($sitePath.'/craft') ? 'web' : 'public';
|
return is_file($sitePath.'/craft') ? 'web' : 'public';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -144,8 +144,10 @@ public function frontControllerPath($sitePath, $siteName, $uri)
|
|||||||
$this->checkMageMode($sitePath);
|
$this->checkMageMode($sitePath);
|
||||||
|
|
||||||
if ('developer' === $this->mageMode) {
|
if ('developer' === $this->mageMode) {
|
||||||
|
$_SERVER['DOCUMENT_ROOT'] = $sitePath;
|
||||||
return $sitePath . '/index.php';
|
return $sitePath . '/index.php';
|
||||||
}
|
}
|
||||||
|
$_SERVER['DOCUMENT_ROOT'] = $sitePath . '/pub';
|
||||||
return $sitePath . '/pub/index.php';
|
return $sitePath . '/pub/index.php';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,10 +11,39 @@ class SculpinValetDriver extends BasicValetDriver
|
|||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function serves($sitePath, $siteName, $uri)
|
public function serves($sitePath, $siteName, $uri)
|
||||||
|
{
|
||||||
|
return $this->isModernSculpinProject($sitePath) ||
|
||||||
|
$this->isLegacySculpinProject($sitePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function isModernSculpinProject($sitePath)
|
||||||
|
{
|
||||||
|
return is_dir($sitePath.'/source') &&
|
||||||
|
is_dir($sitePath.'/output_dev') &&
|
||||||
|
$this->composerRequiresSculpin($sitePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function isLegacySculpinProject($sitePath)
|
||||||
{
|
{
|
||||||
return is_dir($sitePath.'/.sculpin');
|
return is_dir($sitePath.'/.sculpin');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function composerRequiresSculpin($sitePath)
|
||||||
|
{
|
||||||
|
if (! file_exists($sitePath.'/composer.json')) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$composer_json_source = file_get_contents($sitePath.'/composer.json');
|
||||||
|
$composer_json = json_decode($composer_json_source, true);
|
||||||
|
|
||||||
|
if (json_last_error() !== JSON_ERROR_NONE) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return isset($composer_json['require']['sculpin/sculpin']);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mutate the incoming URI.
|
* Mutate the incoming URI.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ class SymfonyValetDriver extends ValetDriver
|
|||||||
public function serves($sitePath, $siteName, $uri)
|
public function serves($sitePath, $siteName, $uri)
|
||||||
{
|
{
|
||||||
return (file_exists($sitePath.'/web/app_dev.php') || file_exists($sitePath.'/web/app.php')) &&
|
return (file_exists($sitePath.'/web/app_dev.php') || file_exists($sitePath.'/web/app.php')) &&
|
||||||
(file_exists($sitePath.'/app/AppKernel.php')) || (file_exists($sitePath.'/web/index.php')) &&
|
(file_exists($sitePath.'/app/AppKernel.php')) || (file_exists($sitePath.'/public/index.php')) &&
|
||||||
(file_exists($sitePath.'/src/Kernel.php'))
|
(file_exists($sitePath.'/src/Kernel.php'))
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
@@ -30,6 +30,8 @@ public function isStaticFile($sitePath, $siteName, $uri)
|
|||||||
{
|
{
|
||||||
if ($this->isActualFile($staticFilePath = $sitePath.'/web/'.$uri)) {
|
if ($this->isActualFile($staticFilePath = $sitePath.'/web/'.$uri)) {
|
||||||
return $staticFilePath;
|
return $staticFilePath;
|
||||||
|
} elseif ($this->isActualFile($staticFilePath = $sitePath.'/public/'.$uri)) {
|
||||||
|
return $staticFilePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@@ -49,7 +51,7 @@ public function frontControllerPath($sitePath, $siteName, $uri)
|
|||||||
return $frontControllerPath;
|
return $frontControllerPath;
|
||||||
} elseif (file_exists($frontControllerPath = $sitePath.'/web/app.php')) {
|
} elseif (file_exists($frontControllerPath = $sitePath.'/web/app.php')) {
|
||||||
return $frontControllerPath;
|
return $frontControllerPath;
|
||||||
} elseif (file_exists($frontControllerPath = $sitePath.'/web/index.php')) {
|
} elseif (file_exists($frontControllerPath = $sitePath.'/public/index.php')) {
|
||||||
return $frontControllerPath;
|
return $frontControllerPath;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
*/
|
*/
|
||||||
Container::setInstance(new Container);
|
Container::setInstance(new Container);
|
||||||
|
|
||||||
$version = '2.0.5';
|
$version = '2.0.12';
|
||||||
|
|
||||||
$app = new Application('Laravel Valet', $version);
|
$app = new Application('Laravel Valet', $version);
|
||||||
|
|
||||||
@@ -253,6 +253,16 @@
|
|||||||
output('NO');
|
output('NO');
|
||||||
}
|
}
|
||||||
})->descriptions('Determine if this is the latest version of Valet');
|
})->descriptions('Determine if this is the latest version of Valet');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Install the sudoers.d entries so password is no longer required.
|
||||||
|
*/
|
||||||
|
$app->command('trust', function () {
|
||||||
|
Brew::createSudoersEntry();
|
||||||
|
Valet::createSudoersEntry();
|
||||||
|
|
||||||
|
info('Sudoers entries have been added for Brew and Valet.');
|
||||||
|
})->descriptions('Add sudoers files for Brew and Valet to make Valet commands run without passwords');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -27,7 +27,7 @@
|
|||||||
"php": ">=5.6",
|
"php": ">=5.6",
|
||||||
"illuminate/container": "~5.1",
|
"illuminate/container": "~5.1",
|
||||||
"mnapoli/silly": "~1.0",
|
"mnapoli/silly": "~1.0",
|
||||||
"symfony/process": "~2.7|~3.0",
|
"symfony/process": "~2.7|~3.0|~4.0",
|
||||||
"nategood/httpful": "~0.2",
|
"nategood/httpful": "~0.2",
|
||||||
"tightenco/collect": "^5.3"
|
"tightenco/collect": "^5.3"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ ## Introduction
|
|||||||
|
|
||||||
Valet is a Laravel development environment for Mac minimalists. No Vagrant, no `/etc/hosts` file. You can even share your sites publicly using local tunnels. _Yeah, we like it too._
|
Valet is a Laravel development environment for Mac minimalists. No Vagrant, no `/etc/hosts` file. You can even share your sites publicly using local tunnels. _Yeah, we like it too._
|
||||||
|
|
||||||
Laravel Valet configures your Mac to always run Nginx in the background when your machine starts. Then, using [DnsMasq](https://en.wikipedia.org/wiki/Dnsmasq), Valet proxies all requests on the `*.dev` domain to point to sites installed on your local machine.
|
Laravel Valet configures your Mac to always run Nginx in the background when your machine starts. Then, using [DnsMasq](https://en.wikipedia.org/wiki/Dnsmasq), Valet proxies all requests on the `*.test` domain to point to sites installed on your local machine.
|
||||||
|
|
||||||
In other words, a blazing fast Laravel development environment that uses roughly 7mb of RAM. Valet isn't a complete replacement for Vagrant or Homestead, but provides a great alternative if you want flexible basics, prefer extreme speed, or are working on a machine with a limited amount of RAM.
|
In other words, a blazing fast Laravel development environment that uses roughly 7mb of RAM. Valet isn't a complete replacement for Vagrant or Homestead, but provides a great alternative if you want flexible basics, prefer extreme speed, or are working on a machine with a limited amount of RAM.
|
||||||
|
|
||||||
|
|||||||
16
server.php
16
server.php
@@ -35,6 +35,20 @@ function valet_support_wildcard_dns($domain)
|
|||||||
return $domain;
|
return $domain;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array $config Valet configuration array
|
||||||
|
*
|
||||||
|
* @return string|null If set, default site path for uncaught urls
|
||||||
|
* */
|
||||||
|
function valet_default_site_path($config)
|
||||||
|
{
|
||||||
|
if (isset($config['default']) && is_string($config['default']) && is_dir($config['default'])) {
|
||||||
|
return $config['default'];
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load the Valet configuration.
|
* Load the Valet configuration.
|
||||||
*/
|
*/
|
||||||
@@ -77,7 +91,7 @@ function valet_support_wildcard_dns($domain)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_null($valetSitePath)) {
|
if (is_null($valetSitePath) && is_null($valetSitePath = valet_default_site_path($valetConfig))) {
|
||||||
show_valet_404();
|
show_valet_404();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -66,38 +66,63 @@ public function test_installed_returns_false_when_given_formula_is_not_installed
|
|||||||
public function test_has_installed_php_indicates_if_php_is_installed_via_brew()
|
public function test_has_installed_php_indicates_if_php_is_installed_via_brew()
|
||||||
{
|
{
|
||||||
$brew = Mockery::mock(Brew::class.'[installed]', [new CommandLine, new Filesystem]);
|
$brew = Mockery::mock(Brew::class.'[installed]', [new CommandLine, new Filesystem]);
|
||||||
|
$brew->shouldReceive('installed')->with('php')->andReturn(true);
|
||||||
$brew->shouldReceive('installed')->with('php72')->andReturn(true);
|
$brew->shouldReceive('installed')->with('php72')->andReturn(true);
|
||||||
$brew->shouldReceive('installed')->with('php71')->andReturn(false);
|
$brew->shouldReceive('installed')->with('php71')->andReturn(false);
|
||||||
$brew->shouldReceive('installed')->with('php70')->andReturn(false);
|
$brew->shouldReceive('installed')->with('php70')->andReturn(false);
|
||||||
$brew->shouldReceive('installed')->with('php56')->andReturn(false);
|
$brew->shouldReceive('installed')->with('php56')->andReturn(false);
|
||||||
|
$brew->shouldReceive('installed')->with('php@7.2')->andReturn(true);
|
||||||
|
$brew->shouldReceive('installed')->with('php@7.1')->andReturn(false);
|
||||||
|
$brew->shouldReceive('installed')->with('php@7.0')->andReturn(false);
|
||||||
|
$brew->shouldReceive('installed')->with('php@5.6')->andReturn(false);
|
||||||
$this->assertTrue($brew->hasInstalledPhp());
|
$this->assertTrue($brew->hasInstalledPhp());
|
||||||
|
|
||||||
$brew = Mockery::mock(Brew::class.'[installed]', [new CommandLine, new Filesystem]);
|
$brew = Mockery::mock(Brew::class.'[installed]', [new CommandLine, new Filesystem]);
|
||||||
|
$brew->shouldReceive('installed')->with('php')->andReturn(false);
|
||||||
$brew->shouldReceive('installed')->with('php72')->andReturn(false);
|
$brew->shouldReceive('installed')->with('php72')->andReturn(false);
|
||||||
$brew->shouldReceive('installed')->with('php71')->andReturn(true);
|
$brew->shouldReceive('installed')->with('php71')->andReturn(true);
|
||||||
$brew->shouldReceive('installed')->with('php70')->andReturn(false);
|
$brew->shouldReceive('installed')->with('php70')->andReturn(false);
|
||||||
$brew->shouldReceive('installed')->with('php56')->andReturn(false);
|
$brew->shouldReceive('installed')->with('php56')->andReturn(false);
|
||||||
|
$brew->shouldReceive('installed')->with('php@7.2')->andReturn(false);
|
||||||
|
$brew->shouldReceive('installed')->with('php@7.1')->andReturn(true);
|
||||||
|
$brew->shouldReceive('installed')->with('php@7.0')->andReturn(false);
|
||||||
|
$brew->shouldReceive('installed')->with('php@5.6')->andReturn(false);
|
||||||
$this->assertTrue($brew->hasInstalledPhp());
|
$this->assertTrue($brew->hasInstalledPhp());
|
||||||
|
|
||||||
$brew = Mockery::mock(Brew::class.'[installed]', [new CommandLine, new Filesystem]);
|
$brew = Mockery::mock(Brew::class.'[installed]', [new CommandLine, new Filesystem]);
|
||||||
|
$brew->shouldReceive('installed')->with('php')->andReturn(false);
|
||||||
$brew->shouldReceive('installed')->with('php72')->andReturn(false);
|
$brew->shouldReceive('installed')->with('php72')->andReturn(false);
|
||||||
$brew->shouldReceive('installed')->with('php71')->andReturn(false);
|
$brew->shouldReceive('installed')->with('php71')->andReturn(false);
|
||||||
$brew->shouldReceive('installed')->with('php70')->andReturn(true);
|
$brew->shouldReceive('installed')->with('php70')->andReturn(true);
|
||||||
$brew->shouldReceive('installed')->with('php56')->andReturn(false);
|
$brew->shouldReceive('installed')->with('php56')->andReturn(false);
|
||||||
|
$brew->shouldReceive('installed')->with('php@7.2')->andReturn(false);
|
||||||
|
$brew->shouldReceive('installed')->with('php@7.1')->andReturn(false);
|
||||||
|
$brew->shouldReceive('installed')->with('php@7.0')->andReturn(true);
|
||||||
|
$brew->shouldReceive('installed')->with('php@5.6')->andReturn(false);
|
||||||
$this->assertTrue($brew->hasInstalledPhp());
|
$this->assertTrue($brew->hasInstalledPhp());
|
||||||
|
|
||||||
$brew = Mockery::mock(Brew::class.'[installed]', [new CommandLine, new Filesystem]);
|
$brew = Mockery::mock(Brew::class.'[installed]', [new CommandLine, new Filesystem]);
|
||||||
|
$brew->shouldReceive('installed')->with('php')->andReturn(false);
|
||||||
$brew->shouldReceive('installed')->with('php72')->andReturn(false);
|
$brew->shouldReceive('installed')->with('php72')->andReturn(false);
|
||||||
$brew->shouldReceive('installed')->with('php71')->andReturn(false);
|
$brew->shouldReceive('installed')->with('php71')->andReturn(false);
|
||||||
$brew->shouldReceive('installed')->with('php70')->andReturn(false);
|
$brew->shouldReceive('installed')->with('php70')->andReturn(false);
|
||||||
$brew->shouldReceive('installed')->with('php56')->andReturn(true);
|
$brew->shouldReceive('installed')->with('php56')->andReturn(true);
|
||||||
|
$brew->shouldReceive('installed')->with('php@7.2')->andReturn(false);
|
||||||
|
$brew->shouldReceive('installed')->with('php@7.1')->andReturn(false);
|
||||||
|
$brew->shouldReceive('installed')->with('php@7.0')->andReturn(false);
|
||||||
|
$brew->shouldReceive('installed')->with('php@5.6')->andReturn(true);
|
||||||
$this->assertTrue($brew->hasInstalledPhp());
|
$this->assertTrue($brew->hasInstalledPhp());
|
||||||
|
|
||||||
$brew = Mockery::mock(Brew::class.'[installed]', [new CommandLine, new Filesystem]);
|
$brew = Mockery::mock(Brew::class.'[installed]', [new CommandLine, new Filesystem]);
|
||||||
|
$brew->shouldReceive('installed')->with('php')->andReturn(false);
|
||||||
$brew->shouldReceive('installed')->with('php72')->andReturn(false);
|
$brew->shouldReceive('installed')->with('php72')->andReturn(false);
|
||||||
$brew->shouldReceive('installed')->with('php71')->andReturn(false);
|
$brew->shouldReceive('installed')->with('php71')->andReturn(false);
|
||||||
$brew->shouldReceive('installed')->with('php70')->andReturn(false);
|
$brew->shouldReceive('installed')->with('php70')->andReturn(false);
|
||||||
$brew->shouldReceive('installed')->with('php56')->andReturn(false);
|
$brew->shouldReceive('installed')->with('php56')->andReturn(false);
|
||||||
|
$brew->shouldReceive('installed')->with('php@7.2')->andReturn(false);
|
||||||
|
$brew->shouldReceive('installed')->with('php@7.1')->andReturn(false);
|
||||||
|
$brew->shouldReceive('installed')->with('php@7.0')->andReturn(false);
|
||||||
|
$brew->shouldReceive('installed')->with('php@5.6')->andReturn(false);
|
||||||
$this->assertFalse($brew->hasInstalledPhp());
|
$this->assertFalse($brew->hasInstalledPhp());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -140,13 +165,13 @@ public function test_linked_php_returns_linked_php_formula_name()
|
|||||||
$files->shouldReceive('isLink')->once()->with('/usr/local/bin/php')->andReturn(true);
|
$files->shouldReceive('isLink')->once()->with('/usr/local/bin/php')->andReturn(true);
|
||||||
$files->shouldReceive('readLink')->once()->with('/usr/local/bin/php')->andReturn('/test/path/php71/test');
|
$files->shouldReceive('readLink')->once()->with('/usr/local/bin/php')->andReturn('/test/path/php71/test');
|
||||||
swap(Filesystem::class, $files);
|
swap(Filesystem::class, $files);
|
||||||
$this->assertSame('php71', resolve(Brew::class)->linkedPhp());
|
$this->assertSame('php@7.1', resolve(Brew::class)->linkedPhp());
|
||||||
|
|
||||||
$files = Mockery::mock(Filesystem::class);
|
$files = Mockery::mock(Filesystem::class);
|
||||||
$files->shouldReceive('isLink')->once()->with('/usr/local/bin/php')->andReturn(true);
|
$files->shouldReceive('isLink')->once()->with('/usr/local/bin/php')->andReturn(true);
|
||||||
$files->shouldReceive('readLink')->once()->with('/usr/local/bin/php')->andReturn('/test/path/php56/test');
|
$files->shouldReceive('readLink')->once()->with('/usr/local/bin/php')->andReturn('/test/path/php56/test');
|
||||||
swap(Filesystem::class, $files);
|
swap(Filesystem::class, $files);
|
||||||
$this->assertSame('php56', resolve(Brew::class)->linkedPhp());
|
$this->assertSame('php@5.6', resolve(Brew::class)->linkedPhp());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use Valet\Brew;
|
||||||
|
use Valet\Valet;
|
||||||
use Valet\Filesystem;
|
use Valet\Filesystem;
|
||||||
use Valet\Configuration;
|
use Valet\Configuration;
|
||||||
use Illuminate\Container\Container;
|
use Illuminate\Container\Container;
|
||||||
@@ -120,4 +122,15 @@ public function test_update_key_updates_the_specified_configuration_key()
|
|||||||
$config->shouldReceive('write')->once()->with(['foo' => 'bar', 'bar' => 'baz']);
|
$config->shouldReceive('write')->once()->with(['foo' => 'bar', 'bar' => 'baz']);
|
||||||
$config->updateKey('bar', 'baz');
|
$config->updateKey('bar', 'baz');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function test_trust_adds_the_sudoer_files()
|
||||||
|
{
|
||||||
|
$files = Mockery::mock(Filesystem::class.'[ensureDirExists,put]');
|
||||||
|
$files->shouldReceive('ensureDirExists')->with('/etc/sudoers.d')->twice();
|
||||||
|
$files->shouldReceive('put')->twice();
|
||||||
|
swap(Filesystem::class, $files);
|
||||||
|
resolve(Brew::class)->createSudoersEntry();
|
||||||
|
resolve(Valet::class)->createSudoersEntry();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ public function test_install_nginx_configuration_places_nginx_base_configuration
|
|||||||
|
|
||||||
$files->shouldReceive('putAsUser')->andReturnUsing(function ($path, $contents) {
|
$files->shouldReceive('putAsUser')->andReturnUsing(function ($path, $contents) {
|
||||||
$this->assertSame('/usr/local/etc/nginx/nginx.conf', $path);
|
$this->assertSame('/usr/local/etc/nginx/nginx.conf', $path);
|
||||||
$this->assertTrue(strpos($contents, 'include '.VALET_HOME_PATH.'/Nginx/*') !== false);
|
$this->assertContains('include '.VALET_HOME_PATH.'/Nginx/*', $contents);
|
||||||
})->once();
|
})->once();
|
||||||
|
|
||||||
swap(Filesystem::class, $files);
|
swap(Filesystem::class, $files);
|
||||||
|
|||||||
@@ -64,6 +64,24 @@ public function test_prune_links_removes_broken_symlinks_in_sites_path()
|
|||||||
$site->pruneLinks();
|
$site->pruneLinks();
|
||||||
$this->assertFileNotExists(__DIR__.'/output/link');
|
$this->assertFileNotExists(__DIR__.'/output/link');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function test_certificates_trim_tld_for_custom_tlds()
|
||||||
|
{
|
||||||
|
$files = Mockery::mock(Filesystem::class);
|
||||||
|
$files->shouldReceive('scandir')->once()->andReturn([
|
||||||
|
'threeletters.dev.crt',
|
||||||
|
'fiveletters.local.crt',
|
||||||
|
]);
|
||||||
|
|
||||||
|
swap(Filesystem::class, $files);
|
||||||
|
|
||||||
|
$site = resolve(Site::class);
|
||||||
|
$certs = $site->getCertificates('fake-cert-path')->flip();
|
||||||
|
|
||||||
|
$this->assertEquals('threeletters', $certs->first());
|
||||||
|
$this->assertEquals('fiveletters', $certs->last());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user