src/Composer/Downloader/FileDownloader.php
public function download(PackageInterface $package, $path, $output = true)
    {
        if (!$package->getDistUrl()) {
            throw new \InvalidArgumentException('The given package is missing url information');
        }

        if ($output) {
            $this->io->writeError("  - Installing <info>" . $package->getName() . "</info> (<comment>" . $package->getFullPrettyVersion() . "</comment>): ", false);
        }

        $urls = $package->getDistUrls();
        while ($url = array_shift($urls)) {
            try {
                $fileName = $this->doDownload($package, $path, $url);
                break;
            } catch (\Exception $e) {
                if ($this->io->isDebug()) {
                    $this->io->writeError('');
                    $this->io->writeError('Failed: ['.get_class($e).'] '.$e->getCode().': '.$e->getMessage());
                } elseif (count($urls)) {
                    $this->io->writeError('');
                    $this->io->writeError(' Failed, trying the next URL ('.$e->getCode().': '.$e->getMessage().')', false);
                }

                if (!count($urls)) {
                    throw $e;
                }
            }
        }

        if ($output) {
            $this->io->writeError('');
        }

        return $fileName;
    }
public function download(PackageInterface $package, $path, $output = true)
    {
        if (!$package->getDistUrl()) {
            throw new \InvalidArgumentException('The given package is missing url information');
        }

        if ($output) {
            $this->io->writeError("  - Installing <info>" . $package->getName() . "</info> (<comment>" . $package->getFullPrettyVersion() . "</comment>): ", false);
        }

        $urls = $package->getDistUrls();
        while ($url = array_shift($urls)) {
            try {
                $fileName = $this->doDownload($package, $path, $url);
                break;
            } catch (\Exception $e) {
                if ($this->io->isDebug()) {
                    $this->io->writeError('');
                    $this->io->writeError('Failed: ['.get_class($e).'] '.$e->getCode().': '.$e->getMessage());
                } elseif (count($urls)) {
                    $this->io->writeError('');
                    $this->io->writeError(' Failed, trying the next URL ('.$e->getCode().': '.$e->getMessage().')', false);
                }

                if (!count($urls)) {
                    throw $e;
                }
            }
        }

        if ($output) {
            $this->io->writeError('');
        }

        return $fileName;
    }
public function download ( PackageInterface $ package , $ path , $ output = true ) { if ( ! $ package -> getDistUrl ( ) ) { throw new \ InvalidArgumentException ( 'The given package is missing url information' ) ; } if ( $ output ) { $ this -> io -> writeError ( "  - Installing <info>" . $ package -> getName ( ) . "</info> (<comment>" . $ package -> getFullPrettyVersion ( ) . "</comment>): " , false ) ; } $ urls = $ package -> getDistUrls ( ) ; while ( $ url = array_shift ( $ urls ) ) { try { $ fileName = $ this -> doDownload ( $ package , $ path , $ url ) ; break ; } catch ( \ Exception $ e ) { if ( $ this -> io -> isDebug ( ) ) { $ this -> io -> writeError ( '' ) ; $ this -> io -> writeError ( 'Failed: [' . get_class ( $ e ) . '] ' . $ e -> getCode ( ) . ': ' . $ e -> getMessage ( ) ) ; } elseif ( count ( $ urls ) ) { $ this -> io -> writeError ( '' ) ; $ this -> io -> writeError ( ' Failed, trying the next URL (' . $ e -> getCode ( ) . ': ' . $ e -> getMessage ( ) . ')' , false ) ; } if ( ! count ( $ urls ) ) { throw $ e ; } } } if ( $ output ) { $ this -> io -> writeError ( '' ) ; } return $ fileName ; }
{@inheritDoc}
{