Laravel Valet Supports Custom Per-Site Drivers

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.


Filed in: News / Valet


Newsletter

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

Laravel News Partners

Laravel Jobs

Software Engineer Lead (PHP)
Remote
CivicPlus, LLC
Full-time Senior Web Developer
Detroit, MI
Wayne State University
Senior Software Engineer
Sydney, Australia
FoodByUs
Full Stack Engineer
Remote or Medford, Oregon
Empire Medical
Laravel Developer (fulltime - Dutch only)
Netherlands
Qbixx | Webservices
Full Stack or Back-End Developer
Alexandria, VA; Tallahassee, FL; Orlando, FL
Marketing for Change
Senior Quality Assurance Engineer
Remote
Bisnow Media