Created
June 19, 2021 02:43
-
-
Save jasonvarga/b6f4b6027b22fce0e1a7f9498dda81ea to your computer and use it in GitHub Desktop.
Valet Driver that supports Statamic 3's static caching
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class LocalValetDriver extends LaravelValetDriver | |
{ | |
public function frontControllerPath($sitePath, $siteName, $uri) | |
{ | |
if ($this->isActualFile($staticPath = $this->getStaticPath($sitePath))) { | |
return $staticPath; | |
} | |
return parent::frontControllerPath($sitePath, $siteName, $uri); | |
} | |
protected function getStaticPath($sitePath) | |
{ | |
$parts = parse_url($_SERVER['REQUEST_URI']); | |
$query = $parts['query'] ?? ''; | |
return $sitePath.'/public/static'.$parts['path'].'_'.$query.'.html'; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment