Skip to content

Instantly share code, notes, and snippets.

@XenitXTD
Created January 2, 2026 18:13
Show Gist options
  • Select an option

  • Save XenitXTD/ac46b84ac817a1f2e02f27dcccfd1539 to your computer and use it in GitHub Desktop.

Select an option

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
<?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