Installer.php:188, Composer\Installer->run() InstallCommand.php:119, Composer\Command\InstallCommand->execute() Command.php:242, Composer\Command\InstallCommand->run() Application.php:843, Composer\Console\Application->doRunCommand() Application.php:193, Composer\Console\Application->doRun() Application.php:254, Composer\Console\Application->doRun() Application.php:117, Composer\Console\Application->run() Application.php:103, Composer\Console\Application->run() composer:57, {main}()
现在执行到Installer的run方法,
// Force update if there is no lock file present if (!$this->update && !$this->locker->isLocked()) { $this->update = true; }
如果当前没有composer.lock文件,则强制update;
$links = array_merge($this->package->getRequires(), $this->package->getDevRequires());
foreach ($links as $link) {
$request->install($link->getTarget(), $link->getConstraint());
}
获取相关包的安装信息
ArchiveDownloader.php:37, Composer\Downloader\ZipDownloader->download() ZipDownloader.php:71, Composer\Downloader\ZipDownloader->download() DownloadManager.php:213, Composer\Downloader\DownloadManager->download() LibraryInstaller.php:197, Composer\Installer\LibraryInstaller->installCode() LibraryInstaller.php:101, Composer\Installer\LibraryInstaller->install() InstallationManager.php:173, Composer\Installer\InstallationManager->install() InstallationManager.php:160, Composer\Installer\InstallationManager->execute() Installer.php:589, Composer\Installer->doInstall() Installer.php:228, Composer\Installer->run() InstallCommand.php:119, Composer\Command\InstallCommand->execute() Command.php:242, Composer\Command\InstallCommand->run() Application.php:843, Composer\Console\Application->doRunCommand() Application.php:193, Composer\Console\Application->doRun() Application.php:254, Composer\Console\Application->doRun() Application.php:117, Composer\Console\Application->run() Application.php:103, Composer\Console\Application->run() composer:57, {main}()
下载最后来到这里
准备下载psr/log
FileDownloader.php:150, Composer\Downloader\ZipDownloader->doDownload() FileDownloader.php:97, Composer\Downloader\ZipDownloader->download() ArchiveDownloader.php:38, Composer\Downloader\ZipDownloader->download() ZipDownloader.php:71, Composer\Downloader\ZipDownloader->download() DownloadManager.php:213, Composer\Downloader\DownloadManager->download() LibraryInstaller.php:197, Composer\Installer\LibraryInstaller->installCode() LibraryInstaller.php:101, Composer\Installer\LibraryInstaller->install() InstallationManager.php:173, Composer\Installer\InstallationManager->install() InstallationManager.php:160, Composer\Installer\InstallationManager->execute() Installer.php:589, Composer\Installer->doInstall() Installer.php:228, Composer\Installer->run() InstallCommand.php:119, Composer\Command\InstallCommand->execute() Command.php:242, Composer\Command\InstallCommand->run() Application.php:843, Composer\Console\Application->doRunCommand() Application.php:193, Composer\Console\Application->doRun() Application.php:254, Composer\Console\Application->doRun() Application.php:117, Composer\Console\Application->run() Application.php:103, Composer\Console\Application->run() composer:57, {main}()
3次下载机会
模拟http请求
$ctx = StreamContextFactory::getContext($fileUrl, $options, array('notification' => array($this, 'callbackGet')));
出现下载提示……
最后一步
protected function getRemoteContents($originUrl, $fileUrl, $context) { $contents = file_get_contents($fileUrl, false, $context); return array(isset($http_response_header) ? $http_response_header : null, $contents); }
处理3和4开头的返回码
if ($statusCode >= 300 && $statusCode <= 399 && $statusCode !== 304 && $this->redirects < $this->maxRedirects)
if ($statusCode && $statusCode >= 400 && $statusCode <= 599)
下载完毕后,解压缩
$this->extract($fileName, $temporaryDir);
public function extract($file, $path) { // Each extract calls its alternative if not available or fails if (self::$isWindows) { $this->extractWithZipArchive($file, $path, false); } else { $this->extractWithSystemUnzip($file, $path, false); } }
解压缩后,将zip文件删掉
$this->filesystem->unlink($fileName);
将解压缩的文件转移一下目录
psr/log包就下载完毕了
然后继续下载循环,依次下载所有包
生成lock文件
$updatedLock = $this->locker->setLockData( array_diff($localRepo->getCanonicalPackages(), $devPackages), $devPackages, $platformReqs, $platformDevReqs, $aliases, $this->package->getMinimumStability(), $this->package->getStabilityFlags(), $this->preferStable || $this->package->getPreferStable(), $this->preferLowest, $this->config->get('platform') ?: array() );
生成autoloader文件
if ($this->dumpAutoloader) { // write autoloader if ($this->optimizeAutoloader) { $this->io->writeError('<info>Generating optimized autoload files</info>'); } else { $this->io->writeError('<info>Generating autoload files</info>'); } $this->autoloadGenerator->setDevMode($this->devMode); $this->autoloadGenerator->setClassMapAuthoritative($this->classMapAuthoritative); $this->autoloadGenerator->setApcu($this->apcuAutoloader); $this->autoloadGenerator->setRunScripts($this->runScripts); $this->autoloadGenerator->dump($this->config, $localRepo, $this->package, $this->installationManager, 'composer', $this->optimizeAutoloader); }
执行script,比如phpunit测试脚本等等
if ($this->runScripts) { // dispatch post event $eventName = $this->update ? ScriptEvents::POST_UPDATE_CMD : ScriptEvents::POST_INSTALL_CMD; $this->eventDispatcher->dispatchScript($eventName, $this->devMode); }
composer install命令就全部执行完毕了
phpunit/phpunit suggests installing phpunit/php-invoker (~1.1)
Writing lock file
Generating autoload files
Process finished with exit code 0