1
0
mirror of https://github.com/laravel/valet.git synced 2026-02-06 16:50:09 +01:00

Add "diagnose" command

This commit is contained in:
Aryeh Raber
2020-04-25 14:27:18 +02:00
parent 605af93982
commit ead9568aca
3 changed files with 83 additions and 0 deletions

71
cli/Valet/Diagnose.php Normal file
View File

@@ -0,0 +1,71 @@
<?php
namespace Valet;
class Diagnose
{
var $commands = [
'sw_vers',
'valet --version',
'cat ~/.config/valet/config.json',
'cat ~/.composer/composer.json',
'composer global diagnose',
'ls -al /etc/sudoers.d/',
'brew config',
'brew services list',
'brew list --versions | grep -E "(php|nginx|dnsmasq|mariadb|mysql|mailhog|openssl)(@\d\..*)?\s"',
'php -v',
'which -a php',
'php --ini',
'nginx -v',
'curl --version',
'php --ri curl',
'~/.composer/vendor/laravel/valet/bin/ngrok version',
'ls -al ~/.ngrok2',
'brew info nginx',
'brew info php',
'brew info openssl',
'openssl version -a',
'openssl ciphers',
'nginx -t',
'which -a php-fpm',
'/usr/local/opt/php/sbin/php-fpm --test',
'/usr/local/opt/php/sbin/php-fpm -y /usr/local/etc/php/7.4/php-fpm.conf --test',
'ls -al ~/Library/LaunchAgents',
'ls -al /Library/LaunchAgents',
'ls -al /Library/LaunchDaemons',
];
var $cli, $files;
/**
* Create a new Diagnose instance.
*
* @param CommandLine $cli
* @param Filesystem $files
* @return void
*/
function __construct(CommandLine $cli, Filesystem $files)
{
$this->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');
}
}