Skip to content

Instantly share code, notes, and snippets.

@aerni
Forked from jasonvarga/LocalValetDriver.php
Created August 18, 2022 21:27
Show Gist options
  • Save aerni/d286a5988b063b9d2d7660f5d53cf709 to your computer and use it in GitHub Desktop.
Save aerni/d286a5988b063b9d2d7660f5d53cf709 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