File tree Expand file tree Collapse file tree 2 files changed +45
-1
lines changed
Expand file tree Collapse file tree 2 files changed +45
-1
lines changed Original file line number Diff line number Diff line change 253253 output ('NO ' );
254254 }
255255 })->descriptions ('Determine if this is the latest version of Valet ' );
256+
257+ /**
258+ * Get or set the fallback site path used by Valet for uncaught urls.
259+ */
260+ $ app ->command ('fallback [path] ' , function ($ path = null ) {
261+ if ($ path === '? ' ) {
262+ if (($ config = Configuration::read ()) && isset ($ config ['fallback ' ])) {
263+ return info ($ config ['fallback ' ]);
264+ } else {
265+ return warning ('Fallback path not set. ' );
266+ }
267+ }
268+
269+ if ($ path && !is_dir ($ path )) {
270+ return warning ('The fallback path [ ' .$ path .'] is not a valid directory. ' );
271+ }
272+
273+ Configuration::updateKey ('fallback ' , $ path ?: getcwd ());
274+
275+ info ('Your Valet fallback path has been updated to ' .($ path === null ? 'the current directory ' : "[ {$ path }] " ).'. ' );
276+ })->descriptions ('Set the current working (or specified) directory as the fallback path for uncaught urls ' );
277+
278+ /**
279+ * Removes the fallback site path used by Valet.
280+ */
281+ $ app ->command ('unfallback ' , function () {
282+ Configuration::updateKey ('fallback ' , null );
283+
284+ info ('Your Valet fallback path has been removed. ' );
285+ })->descriptions ('Remove the fallback site path used for uncaught urls ' );
256286}
257287
258288/**
Original file line number Diff line number Diff line change @@ -35,6 +35,20 @@ function valet_support_xip_io($domain)
3535 return $ domain ;
3636}
3737
38+ /**
39+ * @param array $config Valet configuration array
40+ *
41+ * @return string|null If set, fallback site path for uncaught urls
42+ * */
43+ function valet_fallback_site_path ($ config )
44+ {
45+ if (isset ($ config ['fallback ' ]) && is_string ($ config ['fallback ' ]) && is_dir ($ config ['fallback ' ])) {
46+ return $ config ['fallback ' ];
47+ }
48+
49+ return null ;
50+ }
51+
3852/**
3953 * Load the Valet configuration.
4054 */
@@ -77,7 +91,7 @@ function valet_support_xip_io($domain)
7791 }
7892}
7993
80- if (is_null ($ valetSitePath )) {
94+ if (is_null ($ valetSitePath ) && is_null ( $ valetSitePath = valet_fallback_site_path ( $ valetConfig )) ) {
8195 show_valet_404 ();
8296}
8397
You can’t perform that action at this time.
0 commit comments