Skip to content

Instantly share code, notes, and snippets.

@irfanbaigse
Created January 13, 2022 06:22
Show Gist options
  • Save irfanbaigse/232d5377c137afa45c4d7987b966802f to your computer and use it in GitHub Desktop.
Save irfanbaigse/232d5377c137afa45c4d7987b966802f to your computer and use it in GitHub Desktop.
Local Laravel / Lumen Valet Driver
<?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