PhantomInstaller\Installer::getCdnUrl PHP Method

getCdnUrl() public method

Checks (order by highest precedence on top): - ENV var "PHANTOMJS_CDNURL" - SERVER var "PHANTOMJS_CDNURL" - $['extra']['jakoch/phantomjs-installer']['cdnurl'] in composer.json - default location (bitbucket) == Official Downloads The old versions up to v1.9.2 were hosted on https://phantomjs.googlecode.com/files/ Newer versions are hosted on https://bitbucket.org/ariya/phantomjs/downloads/ Downloads via APIv2: https://api.bitbucket.org/2.0/repositories/ariya/phantomjs/downloads/ == Mirrors NPM USA https://cnpmjs.org/downloads https://cnpmjs.org/mirrors/phantomjs/phantomjs-2.1.1-windows.zip NPM China https://npm.taobao.org/mirrors/phantomjs/ https://npm.taobao.org/mirrors/phantomjs/phantomjs-2.1.1-windows.zip Github, USA, SF https://github.com/Medium/phantomjs/ https://github.com/Medium/phantomjs/releases/download/v2.1.1/phantomjs-2.1.1-windows.zip
public getCdnUrl ( string $version ) : string
$version string
return string URL
    public function getCdnUrl($version)
    {
        $url = '';
        $extraData = $this->getComposer()->getPackage()->getExtra();
        // override the detection of the default URL
        // by checking for an env var and returning early
        if (isset($_ENV['PHANTOMJS_CDNURL'])) {
            $url = $_ENV['PHANTOMJS_CDNURL'];
        } elseif (isset($_SERVER['PHANTOMJS_CDNURL'])) {
            $url = $_SERVER['PHANTOMJS_CDNURL'];
        } elseif (isset($extraData[static::PACKAGE_NAME]['cdnurl'])) {
            $url = $extraData[static::PACKAGE_NAME]['cdnurl'];
        }
        if ($url == '') {
            $url = static::PHANTOMJS_CDNURL_DEFAULT;
        }
        // add slash at the end of the URL, if missing
        if ($url[strlen($url) - 1] != '/') {
            $url .= '/';
        }
        // add version to URL when using "github.com/medium/phantomjs"
        if (substr(strtolower($url), -28) == 'github.com/medium/phantomjs/') {
            $url .= 'releases/download/v' . $version . '/';
        }
        return $url;
    }