1
0
mirror of https://github.com/laravel/valet.git synced 2026-02-04 16:10:08 +01:00

Grueing around

This commit is contained in:
Adam Wathan
2016-10-25 11:57:19 -04:00
parent aeb2a4423b
commit 0da0fb3b1b
5 changed files with 39 additions and 42 deletions

View File

@@ -32,8 +32,8 @@ function __construct(CommandLine $cli, Filesystem $files, Configuration $configu
function install()
{
$this->installCaddyFile();
$this->installCaddyDirectory();
$this->installCaddyDaemon();
// $this->installCaddyDirectory();
// $this->installCaddyDaemon();
}
/**
@@ -46,8 +46,8 @@ function install()
function installCaddyFile()
{
$this->files->putAsUser(
VALET_HOME_PATH.'/Caddyfile',
str_replace(['VALET_HOME_PATH', 'VALET_SERVER_PATH'], [VALET_HOME_PATH, VALET_SERVER_PATH], $this->files->get(__DIR__.'/../stubs/Caddyfile'))
'/usr/local/etc/nginx/servers/valet.conf',
str_replace(['VALET_HOME_PATH', 'VALET_SERVER_PATH'], [VALET_HOME_PATH, VALET_SERVER_PATH], $this->files->get(__DIR__.'/../stubs/valet.conf'))
);
}
@@ -58,16 +58,16 @@ function installCaddyFile()
*
* @return void
*/
function installCaddyDirectory()
{
if (! $this->files->isDir($caddyDirectory = VALET_HOME_PATH.'/Caddy')) {
$this->files->mkdirAsUser($caddyDirectory);
}
// function installCaddyDirectory()
// {
// if (! $this->files->isDir($caddyDirectory = VALET_HOME_PATH.'/Caddy')) {
// $this->files->mkdirAsUser($caddyDirectory);
// }
$this->files->putAsUser($caddyDirectory.'/.keep', "\n");
// $this->files->putAsUser($caddyDirectory.'/.keep', "\n");
$this->rewriteSecureCaddyFiles();
}
// $this->rewriteSecureCaddyFiles();
// }
/**
* Generate fresh Caddyfiles for existing secure sites.
@@ -76,29 +76,29 @@ function installCaddyDirectory()
*
* @return void
*/
function rewriteSecureCaddyFiles()
{
$domain = $this->configuration->read()['domain'];
// function rewriteSecureCaddyFiles()
// {
// $domain = $this->configuration->read()['domain'];
$this->site->resecureForNewDomain($domain, $domain);
}
// $this->site->resecureForNewDomain($domain, $domain);
// }
/**
* Install the Caddy daemon on a system level daemon.
*
* @return void
*/
function installCaddyDaemon()
{
$contents = str_replace(
'VALET_PATH', $this->files->realpath(__DIR__.'/../../'),
$this->files->get(__DIR__.'/../stubs/daemon.plist')
);
// function installCaddyDaemon()
// {
// $contents = str_replace(
// 'VALET_PATH', $this->files->realpath(__DIR__.'/../../'),
// $this->files->get(__DIR__.'/../stubs/daemon.plist')
// );
$this->files->put(
$this->daemonPath, str_replace('VALET_HOME_PATH', VALET_HOME_PATH, $contents)
);
}
// $this->files->put(
// $this->daemonPath, str_replace('VALET_HOME_PATH', VALET_HOME_PATH, $contents)
// );
// }
/**
* Restart the launch daemon.
@@ -107,9 +107,7 @@ function installCaddyDaemon()
*/
function restart()
{
$this->cli->quietly('sudo launchctl unload '.$this->daemonPath);
$this->files->unlink(VALET_HOME_PATH.'/Caddy/.DS_Store');
$this->cli->quietly('sudo launchctl load '.$this->daemonPath);
$this->cli->quietly('sudo brew services restart nginx');
}
/**
@@ -119,7 +117,7 @@ function restart()
*/
function stop()
{
$this->cli->quietly('sudo launchctl unload '.$this->daemonPath);
$this->cli->quietly('sudo brew services stop nginx');
}
/**
@@ -131,6 +129,6 @@ function uninstall()
{
$this->stop();
$this->files->unlink($this->daemonPath);
// $this->files->unlink($this->daemonPath);
}
}

View File

@@ -83,15 +83,14 @@ function createExtensionsDirectory()
}
/**
* Create the directory for Caddy log.
* Create the directory for Nginx logs.
*
* @return void
*/
function createLogDirectory()
{
$this->files->ensureDirExists(VALET_HOME_PATH.'/Log', user());
$this->files->touch(VALET_HOME_PATH.'/Log/access.log');
$this->files->touch(VALET_HOME_PATH.'/Log/error.log');
$this->files->touch(VALET_HOME_PATH.'/Log/nginx-error.log');
}
/**

View File

@@ -61,7 +61,7 @@ function updateConfiguration()
$contents = preg_replace('/^user = .+$/m', 'user = '.user(), $contents);
$contents = preg_replace('/^group = .+$/m', 'group = staff', $contents);
$contents = preg_replace('/^listen = .+$/m', 'listen = 127.0.0.1:9000', $contents);
$contents = preg_replace('/^listen = .+$/m', 'listen = /var/run/fpm-valet.sock', $contents);
$this->files->put($this->fpmConfigPath(), $contents);
}

View File

@@ -10,21 +10,21 @@ server {
}
location / {
rewrite ^ /Users/adamwathan/.composer/vendor/laravel/valet/server.php?$query_string last;
rewrite ^ VALET_SERVER_PATH?$query_string last;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
access_log off;
error_log /Users/adamwathan/nginx-error.log;
error_log VALET_HOME_PATH/Log/nginx-error.log;
error_page 404 /Users/adamwathan/.composer/vendor/laravel/valet/server.php;
error_page 404 VALET_SERVER_PATH;
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/valet/fpm.sock;
fastcgi_index Users/adamwathan/.composer/vendor/laravel/valet/server.php;
fastcgi_pass unix:/var/run/fpm-valet.sock;
fastcgi_index VALET_SERVER_PATH;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;

View File

@@ -29,7 +29,7 @@ public function test_fpm_is_configured_with_the_correct_user_group_and_port()
$contents = file_get_contents(__DIR__.'/output/fpm.conf');
$this->assertTrue(strpos($contents, sprintf("\nuser = %s", user())) !== false);
$this->assertTrue(strpos($contents, "\ngroup = staff") !== false);
$this->assertTrue(strpos($contents, "\nlisten = 127.0.0.1:9000") !== false);
$this->assertTrue(strpos($contents, "\nlisten = /var/run/fpm-valet.sock") !== false);
}
}