-
Hi Sometimes I have a need to serve files from a subfolder of a Valet site, could be a static html or a .php file. How do I configure Valet to do the above ? Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
There's some built-in detection for identifying static assets and serving them direction, but it's more geared around images and stylesheets. You could implement a custom driver that detects certain attributes about your non-Laravel project and therefore loads itself instead of the Laravel driver, and then your custom functionality could serve those files with more specificity. Sorry if that sounds "vague". Can you share a few examples? (Sure, I could guess at some potentials, but some specifics from your use-case would make it easier to set something up to explore.) |
Beta Was this translation helpful? Give feedback.
-
One use case I had recently was that I needed evaluate a paid 3rd party library and they required Ioncube to be installed, the recommended way to install Ioncube is to copy a installation folder to the root of the web and then execute the installation script - that does not work. Another was to get PhpStorm working with XDebug I needed the phpinfo() result so I created a simple file
and put it in my public folder, that does not work on my current project I have Terms and condition, privacy policy pages in different languages, and these pages does not change very often and have more or less no need for php so I wanted them as static html, but that does not work either Sure, I found workaround for all, but... |
Beta Was this translation helpful? Give feedback.
-
Here you go... Create a new custom driver file at: <?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 when Why is this needed? Because (with the present LaravelValetDriver) Valet doesn't check for static |
Beta Was this translation helpful? Give feedback.
Here you go...
Create a new custom driver file at:
/Users/YOUR_USERNAME/.config/valet/Drivers/StaticLaravelValetDriver.php
containing the following:This will cause this custom override driver to be used with your Laravel sites, and…