Created
January 2, 2026 18:13
-
-
Save XenitXTD/ac46b84ac817a1f2e02f27dcccfd1539 to your computer and use it in GitHub Desktop.
A driver for laravel herd to enable it to host a vue 3 application. This will only host a build and doesnt enable HMR
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| namespace Valet\Drivers\Custom; | |
| use Valet\Drivers\LaravelValetDriver; | |
| class Vue3ValetDriver extends LaravelValetDriver | |
| { | |
| /** | |
| * Determine if the driver serves the request. | |
| * | |
| * @param string $sitePath | |
| * @param string $siteName | |
| * @param string $uri | |
| * @return bool | |
| */ | |
| public function serves(string $sitePath, string $siteName, string $uri): bool | |
| { | |
| return file_exists($sitePath . '/dist/index.html') && ( | |
| file_exists($sitePath . '/vite.config.js') || | |
| file_exists($sitePath . '/vite.config.ts') | |
| ); | |
| } | |
| /** | |
| * Determine if the incoming request is for a static file. | |
| * | |
| * @param string $sitePath | |
| * @param string $siteName | |
| * @param string $uri | |
| * @return string|false | |
| */ | |
| public function isStaticFile(string $sitePath, string $siteName, string $uri)/*: string|false */ | |
| { | |
| $path = $sitePath . '/dist' . $uri; | |
| if (file_exists($path) && ! is_dir($path)) { | |
| return $path; | |
| } | |
| return false; | |
| } | |
| /** | |
| * Get the fully resolved path to the application's front controller. | |
| * | |
| * @param string $sitePath | |
| * @param string $siteName | |
| * @param string $uri | |
| * @return string | |
| */ | |
| public function frontControllerPath(string $sitePath, string $siteName, string $uri): ?string | |
| { | |
| return $sitePath . '/dist/index.html'; | |
| } | |
| /** | |
| * Get the logs paths for the application to show in Herds log viewer. | |
| */ | |
| // public function logFilesPaths() { | |
| // return ["/storage/logs"]; | |
| // } | |
| /** | |
| * Display information about the application in the information tab of the Sites UI. | |
| * For Laravel, it's the output of the `php artisan about` command. | |
| */ | |
| // public function siteInformation(string $sitePath, string $phpBinary): array | |
| // { | |
| // try { | |
| // $process = new Process([ | |
| // $phpBinary, | |
| // 'artisan', | |
| // 'about', | |
| // '--json' | |
| // ], $sitePath); | |
| // $process->mustRun(); | |
| // $result = json_decode($process->getOutput(), true); | |
| // } catch (\Exception $e) { | |
| // $result = []; | |
| // } | |
| // return [ | |
| // ...$result, | |
| // ]; | |
| // } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment