composer package updates
[openemr.git] / vendor / illuminate / support / Composer.php
blobbc76aeb24699614a2b0590838fd21590703cdec2
1 <?php
3 namespace Illuminate\Support;
5 use Illuminate\Filesystem\Filesystem;
6 use Symfony\Component\Process\Process;
7 use Symfony\Component\Process\PhpExecutableFinder;
9 class Composer
11 /**
12 * The filesystem instance.
14 * @var \Illuminate\Filesystem\Filesystem
16 protected $files;
18 /**
19 * The working path to regenerate from.
21 * @var string
23 protected $workingPath;
25 /**
26 * Create a new Composer manager instance.
28 * @param \Illuminate\Filesystem\Filesystem $files
29 * @param string|null $workingPath
30 * @return void
32 public function __construct(Filesystem $files, $workingPath = null)
34 $this->files = $files;
35 $this->workingPath = $workingPath;
38 /**
39 * Regenerate the Composer autoloader files.
41 * @param string $extra
42 * @return void
44 public function dumpAutoloads($extra = '')
46 $process = $this->getProcess();
48 $process->setCommandLine(trim($this->findComposer().' dump-autoload '.$extra));
50 $process->run();
53 /**
54 * Regenerate the optimized Composer autoloader files.
56 * @return void
58 public function dumpOptimized()
60 $this->dumpAutoloads('--optimize');
63 /**
64 * Get the composer command for the environment.
66 * @return string
68 protected function findComposer()
70 if ($this->files->exists($this->workingPath.'/composer.phar')) {
71 return ProcessUtils::escapeArgument((new PhpExecutableFinder)->find(false)).' composer.phar';
74 return 'composer';
77 /**
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);
87 /**
88 * Set the working path used by the class.
90 * @param string $path
91 * @return $this
93 public function setWorkingPath($path)
95 $this->workingPath = realpath($path);
97 return $this;