Skip to content

How to serve static or .php files #1430

Answered by drbyte
rabol asked this question in Q&A
Discussion options

You must be logged in to vote

Here you go...

Create a new custom driver file at: /Users/YOUR_USERNAME/.config/valet/Drivers/StaticLaravelValetDriver.php containing the following:

<?php
namespace Valet\Drivers\Custom;

use Valet\Drivers\LaravelValetDriver;

class StaticLaravelValetDriver extends LaravelValetDriver
{
    public function frontControllerPath(string $sitePath, string $siteName, string $uri): ?string
    {
        if (file_exists($staticFilePath = $sitePath.'/public'.$uri)
           && $this->isActualFile($staticFilePath)) {
            return $staticFilePath;
        }

        return $sitePath.'/public/index.php';
    }
}

This will cause this custom override driver to be used with your Laravel sites, and…

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by mattstauffer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants