Created
January 13, 2022 06:22
-
-
Save irfanbaigse/232d5377c137afa45c4d7987b966802f to your computer and use it in GitHub Desktop.
Local Laravel / Lumen 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 | |
// paste this file in root folder of your project | |
// and run command "valet link ." | |
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 (file_exists("$sitePath/bin/Yii")) ? true : 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['SCRIPT_FILENAME'] = "$sitePath/app/web/index.php"; | |
$_SERVER['SCRIPT_NAME'] = "/index.php"; | |
$_SERVER['PHP_SELF'] = "index.php"; | |
$_SERVER['DOCUMENT_ROOT'] = $sitePath; | |
return "$sitePath/app/web/index.php"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment