Laravel Valet Supports Custom Per-Site Drivers
News / May 06, 2017

Laravel Valet Supports Custom Per-Site Drivers

Laravel Valet is an incredible tool for getting a local development environment running in no time at all.

It’s driver based, and each driver adds support for a different type of application, framework, CMS, etc.

If you’d like to add support for something that doesn’t yet exist, it’s pretty simple to create your own driver, and share it with the community.

While there are a number different drivers out of the box, and even more that exist out there, some of them can make assumptions about how your project will be set up.

For example, the Laravel driver assumes your web root is located in a public directory. If you’ve renamed it to public_html, Valet simply won’t recognize that it’s Laravel.

To remedy this, you can create your own local driver that applies for a single project.

Just follow the steps to create a driver, but name it LocalValetDriver.php and place it in your project’s root directory.

<?php

class LocalValetDriver extends LaravelValetDriver
{
    public function serves()
    {
        return true;
    }
    public function frontControllerPath($sitePath, $siteName, $uri)
    {
        return $sitePath.'/public_html/index.php';
    }
}

You can either extend the base ValetDriver class to write the full driver from scratch or extend an existing driver and just override what you need.

Laravel News Partners

Newsletter

Join the weekly newsletter and never miss out on new tips, tutorials, and more.