mirror of
https://github.com/laravel/valet.git
synced 2026-02-07 17:10:05 +01:00
Update drivers location and loading
- Extract much of server.php into a `Server` class - Move all but the Laravel and Basic drivers into a subfolder - Load all but the Laravel and Basic drivers via glob - Add `beforeLoading` hook to simplify the `frontControllerPath` method for some drivers
This commit is contained in:
@@ -12,12 +12,28 @@ class LaravelValetDriver extends ValetDriver
|
||||
* @param string $uri
|
||||
* @return bool
|
||||
*/
|
||||
public function serves($sitePath, $siteName, $uri)
|
||||
public function serves(string $sitePath, string $siteName, string $uri): bool
|
||||
{
|
||||
return file_exists($sitePath.'/public/index.php') &&
|
||||
file_exists($sitePath.'/artisan');
|
||||
}
|
||||
|
||||
/**
|
||||
* Take any steps necessary before loading the front controller for this driver.
|
||||
*
|
||||
* @param string $sitePath
|
||||
* @param string $siteName
|
||||
* @param string $uri
|
||||
* @return void
|
||||
*/
|
||||
public function beforeLoading(string $sitePath, string $siteName, string $uri): void
|
||||
{
|
||||
// Shortcut for getting the "local" hostname as the HTTP_HOST
|
||||
if (isset($_SERVER['HTTP_X_ORIGINAL_HOST'], $_SERVER['HTTP_X_FORWARDED_HOST'])) {
|
||||
$_SERVER['HTTP_HOST'] = $_SERVER['HTTP_X_FORWARDED_HOST'];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the incoming request is for a static file.
|
||||
*
|
||||
@@ -26,7 +42,7 @@ public function serves($sitePath, $siteName, $uri)
|
||||
* @param string $uri
|
||||
* @return string|false
|
||||
*/
|
||||
public function isStaticFile($sitePath, $siteName, $uri)
|
||||
public function isStaticFile(string $sitePath, string $siteName, string $uri): string|false
|
||||
{
|
||||
if (file_exists($staticFilePath = $sitePath.'/public'.$uri)
|
||||
&& is_file($staticFilePath)) {
|
||||
@@ -54,13 +70,8 @@ public function isStaticFile($sitePath, $siteName, $uri)
|
||||
* @param string $uri
|
||||
* @return string
|
||||
*/
|
||||
public function frontControllerPath($sitePath, $siteName, $uri)
|
||||
public function frontControllerPath(string $sitePath, string $siteName, string $uri): string
|
||||
{
|
||||
// Shortcut for getting the "local" hostname as the HTTP_HOST
|
||||
if (isset($_SERVER['HTTP_X_ORIGINAL_HOST'], $_SERVER['HTTP_X_FORWARDED_HOST'])) {
|
||||
$_SERVER['HTTP_HOST'] = $_SERVER['HTTP_X_FORWARDED_HOST'];
|
||||
}
|
||||
|
||||
return $sitePath.'/public/index.php';
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user