diff --git a/cli/Valet/Diagnose.php b/cli/Valet/Diagnose.php new file mode 100644 index 0000000..4b3d199 --- /dev/null +++ b/cli/Valet/Diagnose.php @@ -0,0 +1,71 @@ +cli = $cli; + $this->files = $files; + } + + /** + * Run diagnostics. + */ + function run() + { + $result = collect($this->commands)->map(function ($command) { + $output = $this->cli->runAsUser($command); + + return implode(PHP_EOL, ["$ $command", trim($output)]); + })->implode(PHP_EOL.str_repeat('-', 25).PHP_EOL); + + $this->files->put('valet_diagnostics.txt', $result); + + $this->cli->run('pbcopy < valet_diagnostics.txt'); + + $this->files->unlink('valet_diagnostics.txt'); + } +} diff --git a/cli/includes/facades.php b/cli/includes/facades.php index 2e4acaa..75a6a3c 100644 --- a/cli/includes/facades.php +++ b/cli/includes/facades.php @@ -33,6 +33,7 @@ class Brew extends Facade {} class Nginx extends Facade {} class CommandLine extends Facade {} class Configuration extends Facade {} +class Diagnose extends Facade {} class DnsMasq extends Facade {} class Filesystem extends Facade {} class Ngrok extends Facade {} diff --git a/cli/valet.php b/cli/valet.php index e47a7e2..0fcf219 100755 --- a/cli/valet.php +++ b/cli/valet.php @@ -533,6 +533,17 @@ })->descriptions('Determine directory-listing behavior. Default is off, which means a 404 will display.', [ 'status' => 'on or off. (default=off) will show a 404 page; [on] will display a listing if project folder exists but requested URI not found' ]); + + /** + * Output diagnostics to aid in debugging Valet. + */ + $app->command('diagnose', function () { + info('Running diagnostics...'); + + Diagnose::run(); + + info('Diagnostics output has been copied to your clipboard.'); + })->descriptions('Output diagnostics to aid in debugging Valet.'); } /**