src/Support/Download/UrlDownloader.php
protected function downloadToTempLocalPath($url, $localPath)
    {
        try {
            $ch = curl_init($url);
            curl_setopt($ch, CURLOPT_HEADER, 0);
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
            curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
            curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
            $rawFile = curl_exec($ch);
            curl_close($ch);

            if (false === $rawFile) {
                throw new CouldNotRetrieveRemoteFileException(
                    "curl_exec failed while downloading '{$url}': " . curl_error($ch)
                );
            }

        } catch (Exception $e) {
            throw new CouldNotRetrieveRemoteFileException(
                "Failed to download file content from '{$url}': ",
                $e->getCode(),
                $e
            );
        }

        try {
            if (false === file_put_contents($localPath, $rawFile)) {
                throw new CouldNotRetrieveRemoteFileException('file_put_contents call failed');
            }

        } catch (Exception $e) {

            throw new CouldNotRetrieveRemoteFileException(
                'file_put_contents call threw an exception',
                $e->getCode(),
                $e
            );
        }
    }
protected function downloadToTempLocalPath($url, $localPath)
    {
        try {
            $ch = curl_init($url);
            curl_setopt($ch, CURLOPT_HEADER, 0);
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
            curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
            curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
            $rawFile = curl_exec($ch);
            curl_close($ch);

            if (false === $rawFile) {
                throw new CouldNotRetrieveRemoteFileException(
                    "curl_exec failed while downloading '{$url}': " . curl_error($ch)
                );
            }

        } catch (Exception $e) {
            throw new CouldNotRetrieveRemoteFileException(
                "Failed to download file content from '{$url}': ",
                $e->getCode(),
                $e
            );
        }

        try {
            if (false === file_put_contents($localPath, $rawFile)) {
                throw new CouldNotRetrieveRemoteFileException('file_put_contents call failed');
            }

        } catch (Exception $e) {

            throw new CouldNotRetrieveRemoteFileException(
                'file_put_contents call threw an exception',
                $e->getCode(),
                $e
            );
        }
    }
protected function downloadToTempLocalPath ( $ url , $ localPath ) { try { $ ch = curl_init ( $ url ) ; curl_setopt ( $ ch , CURLOPT_HEADER , 0 ) ; curl_setopt ( $ ch , CURLOPT_RETURNTRANSFER , 1 ) ; curl_setopt ( $ ch , CURLOPT_FOLLOWLOCATION , 1 ) ; curl_setopt ( $ ch , CURLOPT_SSL_VERIFYPEER , 0 ) ; $ rawFile = curl_exec ( $ ch ) ; curl_close ( $ ch ) ; if ( false === $ rawFile ) { throw new CouldNotRetrieveRemoteFileException ( "curl_exec failed while downloading '{$url}': " . curl_error ( $ ch ) ) ; } } catch ( Exception $ e ) { throw new CouldNotRetrieveRemoteFileException ( "Failed to download file content from '{$url}': " , $ e -> getCode ( ) , $ e ) ; } try { if ( false === file_put_contents ( $ localPath , $ rawFile ) ) { throw new CouldNotRetrieveRemoteFileException ( 'file_put_contents call failed' ) ; } } catch ( Exception $ e ) { throw new CouldNotRetrieveRemoteFileException ( 'file_put_contents call threw an exception' , $ e -> getCode ( ) , $ e ) ; } }
Downloads raw file content from a URL to a local path.

@param string $url
@param string $localPath
@throws CouldNotRetrieveRemoteFileException
@codeCoverageIgnore
Downloads raw file content from a URL to a local path .