When you install Valet, a ~/.config/valet/Drivers
directory is created which contains a SampleValetDriver.php
file. This file contains a sample driver implementation to demonstrate how to write a custom driver. Create a file Yii2ValetDriver.php
then paste the Code.
Download the file then run this command cp Yii2ValetDriver.php ~/.config/valet/Drivers/