PhpBrew\Downloader\PhpStreamDownloader::process PHP Method

process() protected method

protected process ( $url, $targetFilePath )
    protected function process($url, $targetFilePath)
    {
        $this->logger->info("Downloading {$url} via php stream");
        $opts = array();
        if ($proxy = $this->options->{'http-proxy'}) {
            $opts['http']['proxy'] = $proxy;
            $opts['http']['request_fulluri'] = true;
            $opts['http']['header'] = array();
            if ($proxyAuth = $this->options->{'http-proxy-auth'}) {
                $opts['http']['header'][] = "Proxy-Authorization: Basic {$proxyAuth}";
            }
        }
        if ($timeout = $this->options->{'connect-timeout'}) {
            $opts['http']['timeout'] = $timeout;
        }
        if ($this->options->{'continue'}) {
            $this->logger->warn('--continue is not support by this download.');
        }
        if (empty($opts)) {
            $binary = file_get_contents($url);
        } else {
            $context = stream_context_create($opts);
            $binary = file_get_contents($url, null, $context);
        }
        if ($binary !== false) {
            file_put_contents($targetFilePath, $binary);
            return true;
        }
        // throw new RuntimeException("Fail to request $url");
        return false;
    }
PhpStreamDownloader