assign() public static method

Find a driver that can serve the incoming request.
public static assign ( string $sitePath, string $siteName, string $uri ) : ValetDriver | null
$sitePath string
$siteName string
$uri string
return ValetDriver | null
Ejemplo n.º 1
0
$valetSitePath = null;
foreach ($valetConfig['paths'] as $path) {
    if (is_dir($path . '/' . $siteName)) {
        $valetSitePath = $path . '/' . $siteName;
        break;
    }
}
if (is_null($valetSitePath)) {
    show_valet_404();
}
/**
 * Find the appropriate Valet driver for the request.
 */
$valetDriver = null;
require __DIR__ . '/cli/drivers/require.php';
$valetDriver = ValetDriver::assign($valetSitePath, $siteName, $uri);
if (!$valetDriver) {
    show_valet_404();
}
/**
 * Overwrite the HTTP host for Ngrok.
 */
if (isset($_SERVER['HTTP_X_ORIGINAL_HOST'])) {
    $_SERVER['HTTP_HOST'] = $_SERVER['HTTP_X_ORIGINAL_HOST'];
}
/**
 * Allow driver to mutate incoming URL.
 */
$uri = $valetDriver->mutateUri($uri);
/**
 * Determine if the incoming request is for a static file.
Ejemplo n.º 2
0
    Caddy::restart();
    info('The [' . $url . '] site has been secured with a fresh TLS certificate.');
})->descriptions('Create a TLS certificate for the specified site');
$app->command('unsecure [domain]', function ($domain = null) {
    $url = ($domain ?: Site::host(getcwd())) . '.' . Configuration::read()['domain'];
    Site::unsecure($url);
    PhpFpm::restart();
    Caddy::restart();
    info('The [' . $url . '] site will now serve traffic over HTTP.');
})->descriptions('Remove a TLS certificate from the specified site');
/**
 * Determine which Valet driver the current directory is using.
 */
$app->command('which', function () {
    require __DIR__ . '/drivers/require.php';
    $driver = ValetDriver::assign(getcwd(), basename(getcwd()), '/');
    if ($driver) {
        info('This site is served by [' . get_class($driver) . '].');
    } else {
        warning('Valet could not determine which driver to use for this site.');
    }
})->descriptions('Determine which Valet driver serves the current working directory');
/**
 * Stream all of the logs for all sites.
 */
$app->command('logs', function () {
    $files = Site::logs(Configuration::read()['paths']);
    $files = collect($files)->transform(function ($file) {
        return escapeshellarg($file);
    })->all();
    if (count($files) > 0) {