13
13
* Example for use it:
14
14
*
15
15
* ```php
16
+ * // Run default commands
16
17
* (new DeployApplication('security_key'))->run();
18
+ *
19
+ * // Run custom commands
20
+ * (new DeployApplication('security_key'))->run([
21
+ * 'echo Hello!', // equal: $ echo Hello!
22
+ * 'php' => '-v' // equal: $ php -v ()
23
+ * ]);
24
+ * // for running "php" used key cause just "php" not working!
17
25
* ```
18
26
*
19
27
* @package optimistex\deploy
@@ -95,7 +103,7 @@ public function end()
95
103
* Returning an absolute path to "php". It is useful, cause just "php" not working!
96
104
* @return string
97
105
*/
98
- public function php ()
106
+ public function php (): string
99
107
{
100
108
if (defined ('PHP_BINDIR ' ) && PHP_BINDIR ) {
101
109
return PHP_BINDIR . '/php ' ;
@@ -109,7 +117,7 @@ public function php()
109
117
return 'php ' ;
110
118
}
111
119
112
- private function checkSecurity ()
120
+ private function checkSecurity (): bool
113
121
{
114
122
if ($ this ->hasAccess === null ) {
115
123
$ this ->hasAccess = false ;
@@ -127,11 +135,14 @@ private function checkSecurity()
127
135
return $ this ->hasAccess ;
128
136
}
129
137
130
- private function exec (array $ commands )
138
+ private function exec (array $ commands ): string
131
139
{
132
140
$ res = "Executing shell commands: \n" ;
133
- foreach ($ commands as $ command ) {
141
+ foreach ($ commands as $ key => $ command ) {
134
142
$ response = [];
143
+ if ($ key === 'php ' ) {
144
+ $ command = $ this ->php () . ' ' . $ command ;
145
+ }
135
146
exec ($ command . ' 2>&1 ' , $ response , $ error_code );
136
147
if ($ error_code > 0 && empty ($ response )) {
137
148
$ response = array ('Error: ' . $ error_code );
0 commit comments