Tutorial: Support non-Laravel apps LocalValetDriver #186
Replies: 7 comments 2 replies
-
I'm getting a 404 error when I drop this in - any tips? |
Beta Was this translation helpful? Give feedback.
-
@thiskbj what does the URL look like? you can try to debug with |
Beta Was this translation helpful? Give feedback.
-
Ah, that helped and it's working now, thank you! The URL looked fine, and my file looks exactly like what you posted, so I think the debugging just helped me understand how to use it. In case this helps someone else, here's my use case:
I downloaded DBnign, started a mysql database, and now I can connect with my databases through phpMyAdmin. Now I can upload my databases for Herd to get started! Thanks again! |
Beta Was this translation helpful? Give feedback.
-
Just a heads up, after upgrading to Herd 1.2 I had to remove the namespace and extend LaravelValetDriver liket this: use Valet\Drivers\LaravelValetDriver;
class LocalValetDriver extends LaravelValetDriver {
// Stuff
} I found it in the official Laravel docs https://laravel.com/docs/10.x/valet#local-drivers since Herd 1.2 now supports custom Valet drivers properly according to the changelog (https://herd.laravel.com/changelog) |
Beta Was this translation helpful? Give feedback.
-
@cord Do we actually need to set up a valet driver for a vanilla php site? |
Beta Was this translation helpful? Give feedback.
-
My Herd setup points to I tried adding the LocalValetDriver in the SPA folder, but it states that:
|
Beta Was this translation helpful? Give feedback.
-
For those of you wanting to use Herd to serve a simple JavaScript application, I was able to serve the production version of a simple JS app built with Vite using the following LocalValetDriver. use Valet\Drivers\ValetDriver;
class LocalValetDriver extends ValetDriver
{
/**
* Determine if the driver serves the request.
*/
public function serves(string $sitePath, string $siteName, string $uri): bool
{
return true;
}
/**
* Determine if the incoming request is for a static file.
*/
public function isStaticFile(string $sitePath, string $siteName, string $uri)/*: string|false */
{
if (file_exists($staticFilePath = $sitePath . '/dist/' . $uri)) {
return $staticFilePath;
}
return false;
}
/**
* Get the fully resolved path to the application's front controller.
*/
public function frontControllerPath(string $sitePath, string $siteName, string $uri): string
{
return $sitePath . '/dist/index.html';
}
} |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Feature Description
Herd can run non-laravel apps with sub-directories, just place the following
LocalValetDriver.php
in your root directory of the test-site.enjoy!
Is this feature valuable for other users as well and why?
because herd is the way to go!
Beta Was this translation helpful? Give feedback.
All reactions