mirror of
https://github.com/laravel/valet.git
synced 2026-02-05 00:20:08 +01:00
Added "fallback" and "unfallback" commands to cli (if valid "fallback" path set, Valet's server script uses it for uncaught urls).
This commit is contained in:
@@ -253,6 +253,36 @@
|
||||
output('NO');
|
||||
}
|
||||
})->descriptions('Determine if this is the latest version of Valet');
|
||||
|
||||
/**
|
||||
* Get or set the fallback site path used by Valet for uncaught urls.
|
||||
*/
|
||||
$app->command('fallback [path]', function ($path = null) {
|
||||
if ($path === '?') {
|
||||
if (($config = Configuration::read()) && isset($config['fallback'])) {
|
||||
return info($config['fallback']);
|
||||
} else {
|
||||
return warning('Fallback path not set.');
|
||||
}
|
||||
}
|
||||
|
||||
if ($path && !is_dir($path)) {
|
||||
return warning('The fallback path ['.$path.'] is not a valid directory.');
|
||||
}
|
||||
|
||||
Configuration::updateKey('fallback', $path ?: getcwd());
|
||||
|
||||
info('Your Valet fallback path has been updated to '.($path === null ? 'the current directory' : "[{$path}]").'.');
|
||||
})->descriptions('Set the current working (or specified) directory as the fallback path for uncaught urls');
|
||||
|
||||
/**
|
||||
* Removes the fallback site path used by Valet.
|
||||
*/
|
||||
$app->command('unfallback', function () {
|
||||
Configuration::updateKey('fallback', null);
|
||||
|
||||
info('Your Valet fallback path has been removed.');
|
||||
})->descriptions('Remove the fallback site path used for uncaught urls');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
16
server.php
16
server.php
@@ -35,6 +35,20 @@ function valet_support_xip_io($domain)
|
||||
return $domain;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $config Valet configuration array
|
||||
*
|
||||
* @return string|null If set, fallback site path for uncaught urls
|
||||
* */
|
||||
function valet_fallback_site_path($config)
|
||||
{
|
||||
if (isset($config['fallback']) && is_string($config['fallback']) && is_dir($config['fallback'])) {
|
||||
return $config['fallback'];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the Valet configuration.
|
||||
*/
|
||||
@@ -77,7 +91,7 @@ function valet_support_xip_io($domain)
|
||||
}
|
||||
}
|
||||
|
||||
if (is_null($valetSitePath)) {
|
||||
if (is_null($valetSitePath) && is_null($valetSitePath = valet_fallback_site_path($valetConfig))) {
|
||||
show_valet_404();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user