@@ -60,12 +60,13 @@ protected function hasPackage($package)
60
60
* @param array<int, string> $packages
61
61
* @param bool $dev
62
62
* @param \Closure|\Symfony\Component\Console\Output\OutputInterface|null $output
63
+ * @param string|null $composerBinary
63
64
* @return bool
64
65
*/
65
- public function requirePackages (array $ packages , bool $ dev = false , Closure |OutputInterface $ output = null )
66
+ public function requirePackages (array $ packages , bool $ dev = false , Closure |OutputInterface $ output = null , $ composerBinary = null )
66
67
{
67
68
$ command = collect ([
68
- ...$ this ->findComposer (),
69
+ ...$ this ->findComposer ($ composerBinary ),
69
70
'require ' ,
70
71
...$ packages ,
71
72
])
@@ -88,12 +89,13 @@ public function requirePackages(array $packages, bool $dev = false, Closure|Outp
88
89
* @param array<int, string> $packages
89
90
* @param bool $dev
90
91
* @param \Closure|\Symfony\Component\Console\Output\OutputInterface|null $output
92
+ * @param string|null $composerBinary
91
93
* @return bool
92
94
*/
93
- public function removePackages (array $ packages , bool $ dev = false , Closure |OutputInterface $ output = null )
95
+ public function removePackages (array $ packages , bool $ dev = false , Closure |OutputInterface $ output = null , $ composerBinary = null )
94
96
{
95
97
$ command = collect ([
96
- ...$ this ->findComposer (),
98
+ ...$ this ->findComposer ($ composerBinary ),
97
99
'remove ' ,
98
100
...$ packages ,
99
101
])
@@ -137,35 +139,40 @@ public function modify(callable $callback)
137
139
* Regenerate the Composer autoloader files.
138
140
*
139
141
* @param string|array $extra
142
+ * @param string|null $composerBinary
140
143
* @return int
141
144
*/
142
- public function dumpAutoloads ($ extra = '' )
145
+ public function dumpAutoloads ($ extra = '' , $ composerBinary = null )
143
146
{
144
147
$ extra = $ extra ? (array ) $ extra : [];
145
148
146
- $ command = array_merge ($ this ->findComposer (), ['dump-autoload ' ], $ extra );
149
+ $ command = array_merge ($ this ->findComposer ($ composerBinary ), ['dump-autoload ' ], $ extra );
147
150
148
151
return $ this ->getProcess ($ command )->run ();
149
152
}
150
153
151
154
/**
152
155
* Regenerate the optimized Composer autoloader files.
153
156
*
157
+ * @param string|null $composerBinary
154
158
* @return int
155
159
*/
156
- public function dumpOptimized ()
160
+ public function dumpOptimized ($ composerBinary = null )
157
161
{
158
- return $ this ->dumpAutoloads ('--optimize ' );
162
+ return $ this ->dumpAutoloads ('--optimize ' , $ composerBinary );
159
163
}
160
164
161
165
/**
162
166
* Get the Composer binary / command for the environment.
163
167
*
168
+ * @param string|null $composerBinary
164
169
* @return array
165
170
*/
166
- public function findComposer ()
171
+ public function findComposer ($ composerBinary = null )
167
172
{
168
- if ($ this ->files ->exists ($ this ->workingPath .'/composer.phar ' )) {
173
+ if (! is_null ($ composerBinary ) && $ this ->files ->exists ($ composerBinary )) {
174
+ return [$ this ->phpBinary (), $ composerBinary ];
175
+ } elseif ($ this ->files ->exists ($ this ->workingPath .'/composer.phar ' )) {
169
176
return [$ this ->phpBinary (), 'composer.phar ' ];
170
177
}
171
178
0 commit comments