Skip to content

Instantly share code, notes, and snippets.

@harrysbaraini
Forked from tliesnham/CoasterValetDriver.php
Created January 12, 2017 19:36
Show Gist options
  • Save harrysbaraini/9b5c5aba2b6599162c51359e09efc799 to your computer and use it in GitHub Desktop.
Save harrysbaraini/9b5c5aba2b6599162c51359e09efc799 to your computer and use it in GitHub Desktop.
<?php
class CoasterValetDriver extends ValetDriver
{
/**
* Determine if the driver serves the request.
*
* @param string $sitePath
* @param string $siteName
* @param string $uri
* @return void
*/
public function serves($sitePath, $siteName, $uri)
{
return is_dir($sitePath.'/public/coaster');
}
/**
* Determine if the incoming request is for a static file.
*
* @param string $sitePath
* @param string $siteName
* @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 (strpos($uri, '/coaster/filemanager') !== false) {
return $sitePath.'/public'.$uri;
}
return $sitePath.'/public/index.php';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment