Last active
February 19, 2017 02:52
-
-
Save pryley/74d48cf2f3b776751d0e3f5da83db454 to your computer and use it in GitHub Desktop.
Laravel Valet driver for Dioscuri
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 DioscuriValetDriver extends BasicValetDriver | |
{ | |
/** | |
* Mutate the incoming URI. | |
* | |
* @param string $uri | |
* @return string | |
*/ | |
public function mutateUri( $uri ) | |
{ | |
return rtrim( '/public' . $uri, '/' ); | |
} | |
/** | |
* 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 is_dir( $sitePath . '/public/app/' ) | |
&& is_dir( $sitePath . '/public/wp/' ) | |
&& file_exists( $sitePath . '/public/wp-config.php' ) | |
&& file_exists( $sitePath . '/env.php' ); | |
} | |
/** | |
* 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, '/wp/' ) !== false ) { | |
$_SERVER['PHP_SELF'] = $uri; | |
return parent::frontControllerPath( $sitePath, $siteName, $uri ); | |
} | |
return $sitePath . '/public/index.php'; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment