protected function _getFromUrl()
    {
        try {
            $http = new Client(['redirect' => 3]); // follow up to 3 redirections
            $response = $http->get($this->params['source'], [], [
                'headers' => [
                    'X-Requested-With' => 'XMLHttpRequest'
                ]
            ]);
        } catch (\Exception $ex) {
            $response = false;
            $this->err(__d('installer', 'Could not download the package. Details: {0}', $ex->getMessage()));

            return false;
        }

        if ($response && $response->isOk()) {
            $this->params['source'] = TMP . substr(md5($this->params['source']), 24) . '.zip';
            $file = new File($this->params['source']);
            $responseBody = $response->body();

            if (is_readable($file->pwd())) {
                $file->delete();
            }

            if (!empty($responseBody) &&
                $file->create() &&
                $file->write($responseBody, 'w+', true)
            ) {
                $file->close();

                return $this->_getFromFile();
                $this->err(__d('installer', 'Unable to extract the package.'));

                return false;
            }

            $this->err(__d('installer', 'Unable to download the file, check write permission on "{0}" directory.', [TMP]));

            return false;
        }

        $this->err(__d('installer', 'Could not download the package, no .ZIP file was found at the given URL.'));

        return false;
    }
protected function _getFromUrl()
    {
        try {
            $http = new Client(['redirect' => 3]); // follow up to 3 redirections
            $response = $http->get($this->params['source'], [], [
                'headers' => [
                    'X-Requested-With' => 'XMLHttpRequest'
                ]
            ]);
        } catch (\Exception $ex) {
            $response = false;
            $this->err(__d('installer', 'Could not download the package. Details: {0}', $ex->getMessage()));

            return false;
        }

        if ($response && $response->isOk()) {
            $this->params['source'] = TMP . substr(md5($this->params['source']), 24) . '.zip';
            $file = new File($this->params['source']);
            $responseBody = $response->body();

            if (is_readable($file->pwd())) {
                $file->delete();
            }

            if (!empty($responseBody) &&
                $file->create() &&
                $file->write($responseBody, 'w+', true)
            ) {
                $file->close();

                return $this->_getFromFile();
                $this->err(__d('installer', 'Unable to extract the package.'));

                return false;
            }

            $this->err(__d('installer', 'Unable to download the file, check write permission on "{0}" directory.', [TMP]));

            return false;
        }

        $this->err(__d('installer', 'Could not download the package, no .ZIP file was found at the given URL.'));

        return false;
    }
protected function _getFromUrl ( ) { try { $ http = new Client ( [ 'redirect' => 3 ] ) ; // follow up to 3 redirections $ response = $ http -> get ( $ this -> params [ 'source' ] , [ ] , [ 'headers' => [ 'X-Requested-With' => 'XMLHttpRequest' ] ] ) ; } catch ( \ Exception $ ex ) { $ response = false ; $ this -> err ( __d ( 'installer' , 'Could not download the package. Details: {0}' , $ ex -> getMessage ( ) ) ) ; return false ; } if ( $ response && $ response -> isOk ( ) ) { $ this -> params [ 'source' ] = TMP . substr ( md5 ( $ this -> params [ 'source' ] ) , 24 ) . '.zip' ; $ file = new File ( $ this -> params [ 'source' ] ) ; $ responseBody = $ response -> body ( ) ; if ( is_readable ( $ file -> pwd ( ) ) ) { $ file -> delete ( ) ; } if ( ! empty ( $ responseBody ) && $ file -> create ( ) && $ file -> write ( $ responseBody , 'w+' , true ) ) { $ file -> close ( ) ; return $ this -> _getFromFile ( ) ; $ this -> err ( __d ( 'installer' , 'Unable to extract the package.' ) ) ; return false ; } $ this -> err ( __d ( 'installer' , 'Unable to download the file, check write permission on "{0}" directory.' , [ TMP ] ) ) ; return false ; } $ this -> err ( __d ( 'installer' , 'Could not download the package, no .ZIP file was found at the given URL.' ) ) ; return false ; }
Prepares install from remote URL.

@return bool True on success
Prepares install from remote URL .