3 namespace Illuminate\Support
;
5 use Illuminate\Filesystem\Filesystem
;
6 use Symfony\Component\Process\Process
;
7 use Symfony\Component\Process\PhpExecutableFinder
;
12 * The filesystem instance.
14 * @var \Illuminate\Filesystem\Filesystem
19 * The working path to regenerate from.
23 protected $workingPath;
26 * Create a new Composer manager instance.
28 * @param \Illuminate\Filesystem\Filesystem $files
29 * @param string|null $workingPath
32 public function __construct(Filesystem
$files, $workingPath = null)
34 $this->files
= $files;
35 $this->workingPath
= $workingPath;
39 * Regenerate the Composer autoloader files.
41 * @param string $extra
44 public function dumpAutoloads($extra = '')
46 $process = $this->getProcess();
48 $process->setCommandLine(trim($this->findComposer().' dump-autoload '.$extra));
54 * Regenerate the optimized Composer autoloader files.
58 public function dumpOptimized()
60 $this->dumpAutoloads('--optimize');
64 * Get the composer command for the environment.
68 protected function findComposer()
70 if ($this->files
->exists($this->workingPath
.'/composer.phar')) {
71 return ProcessUtils
::escapeArgument((new PhpExecutableFinder
)->find(false)).' composer.phar';
78 * Get a new Symfony process instance.
80 * @return \Symfony\Component\Process\Process
82 protected function getProcess()
84 return (new Process('', $this->workingPath
))->setTimeout(null);
88 * Set the working path used by the class.
93 public function setWorkingPath($path)
95 $this->workingPath
= realpath($path);