Skip to content

Instantly share code, notes, and snippets.

@pryley
Last active February 19, 2017 02:52
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 pryley/74d48cf2f3b776751d0e3f5da83db454 to your computer and use it in GitHub Desktop.
Save pryley/74d48cf2f3b776751d0e3f5da83db454 to your computer and use it in GitHub Desktop.
Laravel Valet driver for Dioscuri
<?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