mirror of
https://github.com/laravel/valet.git
synced 2026-02-04 16:10:08 +01:00
Merge pull request #1238 from jjpmann/feature/custom-site-stubs
use getStub to allow custom stub files
This commit is contained in:
@@ -78,7 +78,7 @@ public function createDriversDirectory()
|
||||
|
||||
$this->files->putAsUser(
|
||||
$driversDirectory.'/SampleValetDriver.php',
|
||||
$this->files->get(__DIR__.'/../stubs/SampleValetDriver.php')
|
||||
$this->files->getStub('SampleValetDriver.php')
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -100,7 +100,7 @@ public function ensureUsingDnsmasqDForConfigs()
|
||||
}
|
||||
|
||||
// add a valet-specific config file to point to user's home directory valet config
|
||||
$contents = $this->files->get(__DIR__.'/../stubs/etc-dnsmasq-valet.conf');
|
||||
$contents = $this->files->getStub('etc-dnsmasq-valet.conf');
|
||||
$contents = str_replace('VALET_HOME_PATH', VALET_HOME_PATH, $contents);
|
||||
$this->files->ensureDirExists($this->dnsmasqSystemConfDir, user());
|
||||
$this->files->putAsUser($this->dnsmasqSystemConfDir.'/dnsmasq-valet.conf', $contents);
|
||||
|
||||
@@ -339,4 +339,21 @@ public function scandir($path)
|
||||
return in_array($file, ['.', '..']);
|
||||
})->values()->all();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get custom stub file if exists.
|
||||
*
|
||||
* @param string $filename
|
||||
* @return string
|
||||
*/
|
||||
public function getStub($filename)
|
||||
{
|
||||
$default = __DIR__.'/../stubs/'.$filename;
|
||||
|
||||
$custom = VALET_HOME_PATH.'/stubs/'.$filename;
|
||||
|
||||
$path = file_exists($custom) ? $custom : $default;
|
||||
|
||||
return $this->get($path);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ public function installConfiguration()
|
||||
{
|
||||
info('Installing nginx configuration...');
|
||||
|
||||
$contents = $this->files->get(__DIR__.'/../stubs/nginx.conf');
|
||||
$contents = $this->files->getStub('nginx.conf');
|
||||
|
||||
$this->files->putAsUser(
|
||||
static::NGINX_CONF,
|
||||
@@ -80,13 +80,13 @@ public function installServer()
|
||||
str_replace(
|
||||
['VALET_HOME_PATH', 'VALET_SERVER_PATH', 'VALET_STATIC_PREFIX'],
|
||||
[VALET_HOME_PATH, VALET_SERVER_PATH, VALET_STATIC_PREFIX],
|
||||
$this->site->replaceLoopback($this->files->get(__DIR__.'/../stubs/valet.conf'))
|
||||
$this->site->replaceLoopback($this->files->getStub('valet.conf'))
|
||||
)
|
||||
);
|
||||
|
||||
$this->files->putAsUser(
|
||||
BREW_PREFIX.'/etc/nginx/fastcgi_params',
|
||||
$this->files->get(__DIR__.'/../stubs/fastcgi_params')
|
||||
$this->files->getStub('fastcgi_params')
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -104,7 +104,7 @@ public function createConfigurationFiles($phpVersion)
|
||||
$contents = str_replace(
|
||||
['VALET_USER', 'VALET_HOME_PATH', 'valet.sock'],
|
||||
[user(), VALET_HOME_PATH, self::fpmSockName($phpVersion)],
|
||||
$this->files->get(__DIR__.'/../stubs/etc-phpfpm-valet.conf')
|
||||
$this->files->getStub('etc-phpfpm-valet.conf')
|
||||
);
|
||||
$this->files->put($fpmConfigFile, $contents);
|
||||
|
||||
@@ -114,13 +114,13 @@ public function createConfigurationFiles($phpVersion)
|
||||
|
||||
$this->files->putAsUser(
|
||||
$destDir.'/php-memory-limits.ini',
|
||||
$this->files->get(__DIR__.'/../stubs/php-memory-limits.ini')
|
||||
$this->files->getStub('php-memory-limits.ini')
|
||||
);
|
||||
|
||||
$contents = str_replace(
|
||||
['VALET_USER', 'VALET_HOME_PATH'],
|
||||
[user(), VALET_HOME_PATH],
|
||||
$this->files->get(__DIR__.'/../stubs/etc-phpfpm-error_log.ini')
|
||||
$this->files->getStub('etc-phpfpm-error_log.ini')
|
||||
);
|
||||
$this->files->putAsUser($destDir.'/error_log.ini', $contents);
|
||||
|
||||
|
||||
@@ -689,7 +689,7 @@ public function trustCertificate($crtPath)
|
||||
*/
|
||||
public function buildCertificateConf($path, $url)
|
||||
{
|
||||
$config = str_replace('VALET_DOMAIN', $url, $this->files->get(__DIR__.'/../stubs/openssl.conf'));
|
||||
$config = str_replace('VALET_DOMAIN', $url, $this->files->getStub('openssl.conf'));
|
||||
$this->files->putAsUser($path, $config);
|
||||
}
|
||||
|
||||
@@ -704,7 +704,7 @@ public function buildSecureNginxServer($url, $siteConf = null)
|
||||
{
|
||||
if ($siteConf === null) {
|
||||
$siteConf = $this->replaceOldLoopbackWithNew(
|
||||
$this->files->get(__DIR__.'/../stubs/secure.valet.conf'),
|
||||
$this->files->getStub('secure.valet.conf'),
|
||||
'VALET_LOOPBACK',
|
||||
$this->valetLoopback()
|
||||
);
|
||||
@@ -742,7 +742,7 @@ public function isolate($valetSite, $phpVersion)
|
||||
$siteConf = str_replace(
|
||||
['VALET_HOME_PATH', 'VALET_SERVER_PATH', 'VALET_STATIC_PREFIX', 'VALET_SITE', 'VALET_PHP_FPM_SOCKET', 'VALET_ISOLATED_PHP_VERSION'],
|
||||
[VALET_HOME_PATH, VALET_SERVER_PATH, VALET_STATIC_PREFIX, $valetSite, PhpFpm::fpmSockName($phpVersion), $phpVersion],
|
||||
$this->replaceLoopback($this->files->get(__DIR__.'/../stubs/site.valet.conf'))
|
||||
$this->replaceLoopback($this->files->getStub('site.valet.conf'))
|
||||
);
|
||||
}
|
||||
|
||||
@@ -852,9 +852,7 @@ public function proxyCreate($url, $host, $secure = false)
|
||||
}
|
||||
|
||||
$siteConf = $this->replaceOldLoopbackWithNew(
|
||||
$this->files->get(
|
||||
$secure ? __DIR__.'/../stubs/secure.proxy.valet.conf' : __DIR__.'/../stubs/proxy.valet.conf'
|
||||
),
|
||||
$this->files->getStub($secure ? 'secure.proxy.valet.conf' : 'proxy.valet.conf'),
|
||||
'VALET_LOOPBACK',
|
||||
$this->valetLoopback()
|
||||
);
|
||||
@@ -979,7 +977,7 @@ public function updateLoopbackPlist($loopback)
|
||||
str_replace(
|
||||
'VALET_LOOPBACK',
|
||||
$loopback,
|
||||
$this->files->get(__DIR__.'/../stubs/loopback.plist')
|
||||
$this->files->getStub('loopback.plist')
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
@@ -770,9 +770,9 @@ public function test_can_install_nginx_site_config_for_specific_php_version()
|
||||
|
||||
// When no Nginx file exists, it will create a new config file from the template
|
||||
$files->shouldReceive('exists')->once()->with($siteMock->nginxPath('site2.test'))->andReturn(false);
|
||||
$files->shouldReceive('get')
|
||||
$files->shouldReceive('getStub')
|
||||
->once()
|
||||
->with(dirname(__DIR__).'/cli/Valet/../stubs/site.valet.conf')
|
||||
->with('site.valet.conf')
|
||||
->andReturn(file_get_contents(__DIR__.'/../cli/stubs/site.valet.conf'));
|
||||
|
||||
$files->shouldReceive('putAsUser')
|
||||
|
||||
Reference in New Issue
Block a user