1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Backpack\Base\app\Console\Commands; |
4
|
|
|
|
5
|
|
|
use Illuminate\Console\Command; |
6
|
|
|
use Symfony\Component\Process\Exception\ProcessFailedException; |
7
|
|
|
use Symfony\Component\Process\Process; |
8
|
|
|
|
9
|
|
|
class Version extends Command |
10
|
|
|
{ |
11
|
|
|
/** |
12
|
|
|
* The name and signature of the console command. |
13
|
|
|
* |
14
|
|
|
* @var string |
15
|
|
|
*/ |
16
|
|
|
protected $signature = 'backpack:base:version'; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* The console command description. |
20
|
|
|
* |
21
|
|
|
* @var string |
22
|
|
|
*/ |
23
|
|
|
protected $description = 'Show the version of PHP and Backpack packages.'; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* Execute the console command. |
27
|
|
|
* |
28
|
|
|
* @return mixed |
29
|
|
|
*/ |
30
|
|
|
public function handle() |
31
|
|
|
{ |
32
|
|
|
$this->comment('### PHP VERSION:'); |
33
|
|
|
$this->runConsoleCommand('php -v'); |
34
|
|
|
|
35
|
|
|
$this->comment('### BACKPACK PACKAGES VERSION:'); |
36
|
|
|
$this->runConsoleCommand('composer show | grep "backpack\|laravel/framework"'); |
37
|
|
|
|
38
|
|
|
$this->comment('### MYSQL VERSION:'); |
39
|
|
|
$this->runConsoleCommand('mysql --version'); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* Run a shell command in a separate process. |
44
|
|
|
* |
45
|
|
|
* @param string $command Text to be executed. |
46
|
|
|
* |
47
|
|
|
* @return void |
48
|
|
|
*/ |
49
|
|
|
private function runConsoleCommand($command) |
50
|
|
|
{ |
51
|
|
|
$process = new Process($command, null, null, null, 60, null); |
|
|
|
|
52
|
|
|
$process->run(function ($type, $buffer) { |
53
|
|
|
if (Process::ERR === $type) { |
54
|
|
|
$this->line($buffer); |
55
|
|
|
} else { |
56
|
|
|
$this->line($buffer); |
57
|
|
|
} |
58
|
|
|
}); |
59
|
|
|
|
60
|
|
|
// executes after the command finishes |
61
|
|
|
if (!$process->isSuccessful()) { |
62
|
|
|
throw new ProcessFailedException($process); |
63
|
|
|
} |
64
|
|
|
} |
65
|
|
|
} |
66
|
|
|
|
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: