Skip to content

Instantly share code, notes, and snippets.

@StyxOfDynamite
Last active June 9, 2020 15:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save StyxOfDynamite/13e12d21bef6402ba3a4589ede261a36 to your computer and use it in GitHub Desktop.
Save StyxOfDynamite/13e12d21bef6402ba3a4589ede261a36 to your computer and use it in GitHub Desktop.
Valet Driver - Serve Public Directory Files as Static Content
<?php
class StaticValetDriver extends ValetDriver
{
/**
* Determine if the driver serves the request.
*
* @param string $sitePath
* @param string $siteName
* @param string $uri
* @return bool
*/
public function serves($sitePath, $siteName, $uri)
{
if (file_exists($sitePath.'/false')) {
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)
{
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($sitePath, $siteName, $uri)
{
if (substr($uri, -1) === '/') {
$uri = 'index.php';
}
return $sitePath.'/public/'.$uri;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment