Last active
February 16, 2019 17:20
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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