From 51cf03d36a21d0f0cd4a9eeae60f951d9d82b658 Mon Sep 17 00:00:00 2001 From: Ahmad Fikrizaman Date: Mon, 15 Feb 2021 01:04:32 +0800 Subject: [PATCH] fix: assets not loading due to missing trailing slash --- README.md | 3 +++ install.sh | 2 +- valet/cli/drivers/ValetDriver.php | 25 ++++++++++++++----------- valet/cli/valet.php | 2 +- 4 files changed, 19 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index fa780a0..da791d0 100644 --- a/README.md +++ b/README.md @@ -154,6 +154,9 @@ You probably didn't like the idea of having `www` folder inside this cloned repo To change this, you need to update `.env` file and `DEFAULT_WWW_PATH` to a new path, let say your Desktop. Make sure to use absolute path when defining `DEFAULT_WWW_PATH`. Give it a reload (`butler reload`) and check whether your site still registered with Valet, using `butler parked` or `butler links`. + +**WARNING!!** When changing `DEFAULT_WWW_PATH`, you must end the path with `/`. E.g: `/var/www/` and not `/var/www`. + ### Laravel Queue **[Need better documentation]** diff --git a/install.sh b/install.sh index 6d0cddd..3d78288 100755 --- a/install.sh +++ b/install.sh @@ -47,7 +47,7 @@ fi if [ ! -f .env ]; then cp ./stubs/.env .env - sed -i '' "s|REPLACEME|$PWD/www|g" ./.env + sed -i '' "s|REPLACEME|$PWD/www/|g" ./.env fi if [ ! -f docker-compose.yaml ]; then diff --git a/valet/cli/drivers/ValetDriver.php b/valet/cli/drivers/ValetDriver.php index c766835..21c56c4 100755 --- a/valet/cli/drivers/ValetDriver.php +++ b/valet/cli/drivers/ValetDriver.php @@ -48,7 +48,7 @@ public static function assign($sitePath, $siteName, $uri) $drivers[] = $customSiteDriver; } - $drivers = array_merge($drivers, static::driversIn(VALET_HOME_PATH.'/Drivers')); + $drivers = array_merge($drivers, static::driversIn(VALET_HOME_PATH . '/Drivers')); $drivers[] = 'LaravelValetDriver'; @@ -90,11 +90,11 @@ public static function assign($sitePath, $siteName, $uri) */ public static function customSiteDriver($sitePath) { - if (! file_exists($sitePath.'/LocalValetDriver.php')) { + if (!file_exists($sitePath . '/LocalValetDriver.php')) { return; } - require_once $sitePath.'/LocalValetDriver.php'; + require_once $sitePath . '/LocalValetDriver.php'; return 'LocalValetDriver'; } @@ -107,15 +107,15 @@ public static function customSiteDriver($sitePath) */ public static function driversIn($path) { - if (! is_dir($path)) { + if (!is_dir($path)) { return []; } $drivers = []; - $dir = new RecursiveDirectoryIterator($path); + $dir = new RecursiveDirectoryIterator($path); $iterator = new RecursiveIteratorIterator($dir); - $regex = new RegexIterator($iterator, '/^.+ValetDriver\.php$/i', RecursiveRegexIterator::GET_MATCH); + $regex = new RegexIterator($iterator, '/^.+ValetDriver\.php$/i', RecursiveRegexIterator::GET_MATCH); foreach ($regex as $file) { require_once $file[0]; @@ -177,7 +177,7 @@ public function serveStaticFile($staticFilePath, $sitePath, $siteName, $uri) */ protected function isActualFile($path) { - return ! is_dir($path) && file_exists($path); + return !is_dir($path) && file_exists($path); } /** @@ -191,10 +191,10 @@ protected function isActualFile($path) public function loadServerEnvironmentVariables($sitePath, $siteName) { $varFilePath = $sitePath . '/.valet-env.php'; - if (! file_exists($varFilePath)) { + if (!file_exists($varFilePath)) { $varFilePath = VALET_HOME_PATH . '/.valet-env.php'; } - if (! file_exists($varFilePath)) { + if (!file_exists($varFilePath)) { return; } @@ -207,9 +207,12 @@ public function loadServerEnvironmentVariables($sitePath, $siteName) } foreach ($variablesToSet as $key => $value) { - if (! is_string($key)) continue; + if (!is_string($key)) { + continue; + } + $_SERVER[$key] = $value; - $_ENV[$key] = $value; + $_ENV[$key] = $value; putenv($key . '=' . $value); } } diff --git a/valet/cli/valet.php b/valet/cli/valet.php index 87ba6cc..05101df 100755 --- a/valet/cli/valet.php +++ b/valet/cli/valet.php @@ -31,7 +31,7 @@ */ Container::setInstance(new Container); -$version = '0.0.2'; +$version = '0.0.3'; $app = new Application('Laravel Valet (Butler)', $version);