Created
September 18, 2018 13:58
-
-
Save dougblackjr/db64bba5e38004dcebfd5c8d3da3baee to your computer and use it in GitHub Desktop.
Laravel Valet Driver for ExpressionEngine
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 | |
/** | |
* Laravel Valet Driver for ExpressionEngine | |
* To install: | |
* 1) Install Valet | |
* 2) Add this file to the document/project root | |
*/ | |
class LocalValetDriver extends ValetDriver { | |
/** | |
* Determine if the driver serves the request. | |
* | |
* @param string $sitePath | |
* @param string $siteName | |
* @param string $uri | |
* @return bool | |
*/ | |
public function serves($sitePath, $siteName, $uri) { | |
// Use this to check whether the test file exists, or return true | |
// return file_exists($sitePath.'/file-that-identifies-my-framework'); | |
return true; | |
} | |
/** | |
* Determine if the incoming request is for a static file. | |
* | |
* @param string $sitePath | |
* @param string $siteName | |
* @param string $uri | |
* @return string|false | |
*/ | |
public function isStaticFile($sitePath, $siteName, $uri) { | |
if (file_exists($staticFilePath = $sitePath . '/html/' . $uri)) { | |
return $staticFilePath; | |
} | |
return false; | |
} | |
/** | |
* Get the fully resolved path to the application's front controller. Includes checking for admin panel | |
* | |
* @param string $sitePath | |
* @param string $siteName | |
* @param string $uri | |
* @return string | |
*/ | |
public function frontControllerPath($sitePath, $siteName, $uri) { | |
if (strpos($uri, '/admin') === 0) { | |
return $sitePath . '/html/admin.php'; | |
} | |
return $sitePath . '/html/index.php'; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment