Skip to content

Instantly share code, notes, and snippets.

@Chrisedmo
Created February 1, 2017 10:29
Show Gist options
  • Save Chrisedmo/a5aacb219cb5b05a01613e50f3b4402b to your computer and use it in GitHub Desktop.
Save Chrisedmo/a5aacb219cb5b05a01613e50f3b4402b to your computer and use it in GitHub Desktop.
Craft 3 Composer Install Valet Driver
<?php
class Craft3ValetDriver extends ValetDriver
/* https://github.com/laravel/valet/blob/master/cli/drivers/CraftValetDriver.php */
{
/**
* 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.'/vendor/craftcms/cms');
}
/**
* 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.'/web/'.$uri)) {
return $staticFilePath;
}
return 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.'/web/index.php';
$_SERVER['SERVER_NAME'] = $_SERVER['HTTP_HOST'];
$_SERVER['SCRIPT_NAME'] = '/index.php';
return $sitePath.'/web/index.php';
}
}
@Chrisedmo
Copy link
Author

Just drop this into the following folder > /Users/[your user name]/.valet/Drivers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment