1 | <?php |
||
17 | class Binary extends \yii\base\Object |
||
18 | { |
||
19 | /** |
||
20 | * @var BinariesController parent controller |
||
21 | */ |
||
22 | public $controller; |
||
23 | |||
24 | /** |
||
25 | * @var string command name, eg.: phpunit, composer |
||
26 | */ |
||
27 | public $name; |
||
28 | |||
29 | /** |
||
30 | * @var string full path to the binary, eg.: /usr/bin/git |
||
31 | */ |
||
32 | protected $_path; |
||
33 | |||
34 | /** |
||
35 | * @var string full command to run the binary, possibly with added command runner, eg.: /usr/bin/env php /home/user/command.phar |
||
36 | */ |
||
37 | protected $_command; |
||
38 | |||
39 | /** |
||
40 | * @var string package full name, e.g. pytest |
||
41 | */ |
||
42 | public $package; |
||
43 | |||
44 | /** |
||
45 | * @var string package version constraint, e.g. ^1.1 |
||
46 | */ |
||
47 | public $version; |
||
48 | |||
49 | /** |
||
50 | * @var string installer URL |
||
51 | */ |
||
52 | public $installer; |
||
53 | |||
54 | /** |
||
55 | * @var array installer options |
||
56 | */ |
||
57 | public $installer_options = []; |
||
58 | |||
59 | /** |
||
60 | * @var string URL to download binary |
||
61 | */ |
||
62 | public $download; |
||
63 | |||
64 | /** |
||
65 | * @var string filename to be added to VCS ignore file |
||
66 | */ |
||
67 | protected $_vcsignore; |
||
68 | |||
69 | /** |
||
70 | * Prepares and runs with passthru, returns exit code. |
||
71 | * @param string|array $args |
||
72 | * @return int exit code |
||
73 | */ |
||
74 | public function passthru($args = []) |
||
80 | |||
81 | /** |
||
82 | * Prepares and runs with exec, returns stdout array. |
||
83 | * @param string|array $args |
||
84 | * @param bool $returnExitCode default false |
||
85 | * @return array|int stdout or exit code |
||
86 | */ |
||
87 | public function exec($args = [], $returnExitCode = false) |
||
93 | |||
94 | /** |
||
95 | * Prepare full command line ready for execution. |
||
96 | * @param string|array $args |
||
97 | * @return string |
||
98 | */ |
||
99 | public function prepareCommand($args) |
||
116 | |||
117 | public function install() |
||
121 | |||
122 | /** |
||
123 | * Setter for path. |
||
124 | * @param string $value the path |
||
125 | */ |
||
126 | public function setPath($value) |
||
130 | |||
131 | /** |
||
132 | * Getter for path. |
||
133 | * @return string |
||
134 | */ |
||
135 | public function getPath() |
||
143 | |||
144 | /** |
||
145 | * Detects how to run the binary with `which` utility. |
||
146 | * @param string $name |
||
147 | * @return string path to the binary |
||
148 | */ |
||
149 | public function detectPath($name) |
||
153 | |||
154 | /** |
||
155 | * Setter for command. |
||
156 | * @param string $value the command |
||
157 | */ |
||
158 | public function setCommand($value) |
||
162 | |||
163 | /** |
||
164 | * @return string full command to run the binary |
||
165 | */ |
||
166 | public function getCommand() |
||
174 | |||
175 | /** |
||
176 | * Detects command to run the given path, e.g. /usr/bin/env php /the/dir/command.phar. |
||
177 | * @return string path to the binary |
||
178 | */ |
||
179 | public function detectCommand($path) |
||
195 | |||
196 | public function getVcsignore() |
||
200 | } |
||
201 |