Last active
April 29, 2019 16:57
-
-
Save trk/9533d9c11ab1a14b0c1c78a9cd890b5c to your computer and use it in GitHub Desktop.
https://github.com/phpMv/ubiquity Ubiquity Laravel Valet Driver
This file contains hidden or 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 UbiquityValetDriver extends BasicValetDriver | |
{ | |
/** | |
* 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(is_dir($sitePath . DIRECTORY_SEPARATOR . '.ubiquity')) { | |
return true; | |
} | |
return false; | |
} | |
public function isStaticFile($sitePath, $siteName, $uri) | |
{ | |
if(is_file($sitePath . $uri)) { | |
return $sitePath . $uri; | |
} | |
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) | |
{ | |
$_SERVER['DOCUMENT_ROOT'] = $sitePath; | |
$_SERVER['SCRIPT_NAME'] = '/index.php'; | |
$_SERVER['SCRIPT_FILENAME'] = $sitePath . '/index.php'; | |
$_SERVER['DOCUMENT_URI'] = $sitePath . '/index.php'; | |
$_SERVER['PHP_SELF'] = '/index.php'; | |
$_GET['c'] = ''; | |
if($uri) { | |
$_GET['c'] = ltrim($uri, '/'); | |
$_SERVER['PHP_SELF'] = $_SERVER['PHP_SELF']. $uri; | |
$_SERVER['PATH_INFO'] = $uri; | |
} | |
$indexPath = $sitePath . '/index.php'; | |
if(file_exists($indexPath)) { | |
return $indexPath; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment