Custom Drivers
You can extend Herd with your own drivers to support customized setups of supported frameworks or to add new frameworks and applications that Herd doesn’t support out of the box. You can also change the application information thatherd site-information returns or add additional log file directories for the Log Viewer.
What is a driver?
A driver is a PHP class that tells Herd how to serve a site. When a request comes in, Herd goes through its drivers and uses the first one that recognizes the site directory — a Laravel site is detected by itsartisan file, a WordPress site by wp-config.php, and so on.
Once a driver has claimed the site, it decides how the request is handled: whether it’s a static file like an image or a stylesheet that can be served straight from disk, and which PHP file should handle everything else. For Laravel, that front controller is public/index.php.
Herd ships with drivers for every framework it supports, so a standard Laravel, Statamic, or WordPress site just works and you never have to think about drivers. You only need your own when a site breaks those conventions — it’s served from a web directory instead of public, for example — or when you use a framework Herd doesn’t know yet.
Drivers also decide which log files the Log Viewer scans and what herd site-information returns for a site. Both can be customized per site, as described below.
Creating a driver
Herd internally leverages a heavily customized version of Laravel Valet for serving sites, and it includes all drivers that Valet provides. These drivers are a good start when creating your own custom driver, and it often makes sense to further extend them than starting from scratch.Please make sure to name the custom driver according to the driver convention. It needs to end on
ValetDriver.php and a good name for a custom Laravel driver would be MyLaravelValetDriver.php.Customize Herds behaviour
Log paths
You can customize the paths that are checked for the log viewer by adjusting thelogFilesPaths() method in the driver. The default looks like this:
Application Information
Theherd site-information command returns an overview of your application and you can customize this information to your needs. The default for Laravel applications is the output of the php artisan about command.
If you want to customize the overview table, you can do so by defining this method in your applications’ custom driver and returning an array like the following:
Custom Laravel Driver
This example of a custom driver extends the existing Laravel Driver and modifies it to serve the application from aweb instead of the public directory.
phpBinary and $sitePath variables.