Skip to content

Instantly share code, notes, and snippets.

@ahmu83
Last active February 16, 2019 17:20
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 ahmu83/cf878aba5af1c09a38fec048052c8c28 to your computer and use it in GitHub Desktop.
Save ahmu83/cf878aba5af1c09a38fec048052c8c28 to your computer and use it in GitHub Desktop.
This is a valet driver which changes the root directory of a valet site using a file .rootdir which contains the directory and the entry file. i.e, /www/home.php
<?php
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($sitePath, $siteName, $uri) {
return true;
}
/**
* Get the fully resolved path to the application's front controller.
* This will check for the file .rootdir in the directory containing the entry directory/file
*
* @param string $sitePath
* @param string $siteName
* @param string $uri
* @return string
*/
public function frontControllerPath($sitePath, $siteName, $uri) {
$entry = file_exists("{$sitePath}/.rootdir") ? file_get_contents("{$sitePath}/.rootdir") : '/index.php';
$entry = !empty($entry) ? $entry : '/index.php';
$sitePath = $sitePath . $entry;
return $sitePath;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment