Skip to content

Instantly share code, notes, and snippets.

@dougblackjr
Created October 24, 2023 19:50
Show Gist options
  • Save dougblackjr/1fa4078d91d55ad3a5ab473b40a68c05 to your computer and use it in GitHub Desktop.
Save dougblackjr/1fa4078d91d55ad3a5ab473b40a68c05 to your computer and use it in GitHub Desktop.
ExpressionEngine Location Valet Driver - 2023
<?php
use Valet\Drivers\LaravelValetDriver;
class LocalValetDriver extends LaravelValetDriver
{
/**
* Determine if the driver serves the request.
*
* @param string $sitePath
* @param string $siteName
* @param string $uri
* @return bool
*/
public function serves(string $sitePath, string $siteName, string $uri): bool
{
if (is_dir($sitePath . '/system') && is_dir($sitePath . '/system/ee')) {
return true;
}
return false;
}
/**
* Determine if the incoming request is for a static file.
*
* @param string $sitePath
* @param string $siteName
* @param string $uri
* @return string|false
*/
public function isStaticFile($sitePath, $siteName, $uri)
{
// This assumes that your static files are in the public directory. Change that folder if you need.
if (file_exists($staticFilePath = $sitePath . '/public/' . $uri)) {
return $staticFilePath;
}
return false;
}
/**
* Get the fully resolved path to the application's front controller.
*
* @param string $sitePath
* @param string $siteName
* @param string $uri
* @return string
*/
public function frontControllerPath(string $sitePath, string $siteName, string $uri): ?string
{
// This assumes that your static files are in the public directory. Change that folder if you need.
if ($uri == '/admin.php') {
return $sitePath . '/public/admin.php';
}
return $sitePath . '/public/index.php';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment