"Warning: require_once(./cli/includes/require-drivers.php): Failed to open stream" when using custom Laravel Valet driver for Symfony project - Hack The Tech - Latest News related to Computer and Technology

Hack The Tech - Latest News related to Computer and Technology

Get Daily Latest News related to Computer and Technology and hack the world.

Thursday, August 17, 2023

"Warning: require_once(./cli/includes/require-drivers.php): Failed to open stream" when using custom Laravel Valet driver for Symfony project

I'm trying to create a custom Laravel Valet driver for a Symfony project as I need to handle asset files in a specific way. I've created the following ProjectValetDriver class in /.config/valet/Drivers

<?php

namespace Valet\Drivers\Custom;

use Valet\Drivers\LaravelValetDriver;

class ProjectValetDriver extends LaravelValetDriver
{
    public function serves(string $sitePath, string $siteName, string $uri): bool
    {
        return $siteName === '[project-name]';
    }

    public function isStaticFile(string $sitePath, string $siteName, string $uri): string|false
    {
        if (file_exists($staticFilePath = $sitePath.'/public/'.$uri)) {
            return $staticFilePath;
        }

        return false;
    }

    public function frontControllerPath(string $sitePath, string $siteName, string $uri): string
    {
        return $sitePath.'/public/index.php';
    }
}

The custom driver is correctly registered, however when I visit the site I get the following error;

Warning: require_once(./cli/includes/require-drivers.php): Failed to open stream: No such file or directory in /Users/[user]/.composer/vendor/laravel/valet/server.php on line 3

The public/index.php file is called correctly as well, but that file calling require_once dirname(__DIR__) . '/vendor/autoload_runtime.php'; seems to break everything. Without the custom driver the site loads fine. Any idea what's going on?



source https://stackoverflow.com/questions/76916055/warning-require-once-cli-includes-require-drivers-php-failed-to-open-strea

No comments:

Post a Comment