Custom Drivers
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 tab in the Site Manager or add additional log file directories for the Log Viewer.
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
.
Place your custom driver in the related valet directory on your machine and Herd loads it before serving a site automatically.
Customize Herds behaviour
Log paths
You can customize the paths where the log viewer looks for log files by adjusting the logFilesPaths()
method in the driver. The default looks like this:
The given paths are relative to the application root.
Application Information
The Site Manager shows a tabular overview of your application in the information tab 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:
Herd injects the path to the current site and the PHP binary to this method so that you can perform more specific commands and even run code with the correct php version.
Custom Laravel Driver Example
This example of a custom driver extends the existing Laravel Driver and modifies it to serve the application from a web
instead of the public
directory.
This example driver provides a good overview about the possibilities and make use of the phpBinary
and $sitePath
variables.