Skip to content

Instantly share code, notes, and snippets.

@jasonvarga
Created June 19, 2021 02:43
Show Gist options
  • Save jasonvarga/b6f4b6027b22fce0e1a7f9498dda81ea to your computer and use it in GitHub Desktop.
Save jasonvarga/b6f4b6027b22fce0e1a7f9498dda81ea to your computer and use it in GitHub Desktop.
Valet Driver that supports Statamic 3's static caching
<?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