mirror of
https://github.com/laravel/valet.git
synced 2026-02-07 09:10:03 +01:00
Improve GenericPhpValetDriver, remove unnecessary check in WP driver
This commit is contained in:
@@ -28,7 +28,7 @@ public function isStaticFile($sitePath, $siteName, $uri)
|
|||||||
{
|
{
|
||||||
if (file_exists($staticFilePath = $sitePath.'/public'.$uri)) {
|
if (file_exists($staticFilePath = $sitePath.'/public'.$uri)) {
|
||||||
return $staticFilePath;
|
return $staticFilePath;
|
||||||
} elseif (file_exists($staticFilePath = $sitePath.$uri)) {
|
} elseif (file_exists($staticFilePath = $sitePath.$uri) && ! is_dir($staticFilePath)) {
|
||||||
return $staticFilePath;
|
return $staticFilePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -45,14 +45,50 @@ public function isStaticFile($sitePath, $siteName, $uri)
|
|||||||
*/
|
*/
|
||||||
public function frontControllerPath($sitePath, $siteName, $uri)
|
public function frontControllerPath($sitePath, $siteName, $uri)
|
||||||
{
|
{
|
||||||
if (file_exists($frontControllerPath = $sitePath.'/public/index.php')) {
|
$candidates = [
|
||||||
$_SERVER['SCRIPT_FILENAME'] = $sitePath.'/public/index.php';
|
$this->asActualFile($sitePath, $uri),
|
||||||
$_SERVER['SCRIPT_NAME'] = '/index.php';
|
$this->asIndexFileInDirectory($sitePath, $uri),
|
||||||
} elseif (file_exists($frontControllerPath = $sitePath.'/index.php')) {
|
];
|
||||||
$_SERVER['SCRIPT_FILENAME'] = $sitePath.'/index.php';
|
|
||||||
$_SERVER['SCRIPT_NAME'] = '/index.php';
|
foreach ($candidates as $candidate) {
|
||||||
|
if ($this->isActualFile($candidate)) {
|
||||||
|
$_SERVER['SCRIPT_FILENAME'] = $candidate;
|
||||||
|
$_SERVER['SCRIPT_NAME'] = str_replace($sitePath, '', $candidate);
|
||||||
|
return $candidate;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $frontControllerPath;
|
$candidates = [
|
||||||
|
$this->asPublicIndexFile($sitePath, $uri),
|
||||||
|
// ...and other possible public prefixes
|
||||||
|
];
|
||||||
|
|
||||||
|
foreach ($candidates as $candidate) {
|
||||||
|
if ($this->isActualFile($candidate)) {
|
||||||
|
$_SERVER['SCRIPT_FILENAME'] = $candidate;
|
||||||
|
$_SERVER['SCRIPT_NAME'] = '/index.php';
|
||||||
|
return $candidate;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function isActualFile($path)
|
||||||
|
{
|
||||||
|
return file_exists($path) && ! is_dir($path);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function asActualFile($sitePath, $uri)
|
||||||
|
{
|
||||||
|
return $sitePath.$uri;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function asIndexFileInDirectory($sitePath, $uri)
|
||||||
|
{
|
||||||
|
return $sitePath.rtrim($uri, '/').'/index.php';
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function asPublicIndexFile($sitePath, $uri)
|
||||||
|
{
|
||||||
|
return $sitePath.'/public/index.php';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,8 +26,7 @@ public function serves($sitePath, $siteName, $uri)
|
|||||||
public function isStaticFile($sitePath, $siteName, $uri)
|
public function isStaticFile($sitePath, $siteName, $uri)
|
||||||
{
|
{
|
||||||
if (file_exists($sitePath.$uri) &&
|
if (file_exists($sitePath.$uri) &&
|
||||||
! is_dir($sitePath.$uri) &&
|
! is_dir($sitePath.$uri)) {
|
||||||
pathinfo($sitePath.$uri)['extension'] != 'php') {
|
|
||||||
return $sitePath.$uri;
|
return $sitePath.$uri;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user