PHP Class PhantomInstaller\Installer

Mostra file Open project: jakoch/phantomjs-installer Class Usage Examples

Protected Properties

Property Type Description
$composer Composer\Composer
$io Composer\IO\BaseIO

Public Methods

Method Description
__construct ( Composer\Composer $composer, Composer\IO\BaseIO $io )
__invoke ( )
copyPhantomJsBinaryToBinFolder ( string $targetDir, string $binDir ) : boolean Copies the PhantomJs binary to the bin folder.
createComposerInMemoryPackage ( string $targetDir, string $version ) : Composer\Package\Package Returns a Composer Package, which was created in memory.
download ( string $targetDir, string $version ) : boolean The main download function.
dropClassWithPathToInstalledBinary ( string $binaryPath ) : boolean Drop php class with path to installed phantomjs binary for easier usage.
getBitSize ( ) : string Returns the Bit-Size.
getCdnUrl ( string $version ) : string Returns the base URL for downloads.
getComposer ( ) : Composer\Composer
getIO ( ) : Composer\IO\BaseIO
getLatestPhantomJsVersion ( ) : string Returns the latest PhantomJsVersion.
getLowerVersion ( string $old_version ) : string Returns a lower version for a version number.
getOS ( ) : string Returns the Operating System.
getPhantomJsBinary ( string $binDir ) : string | boolean Get path to PhantomJS binary.
getPhantomJsVersionFromBinary ( string $pathToBinary ) : string Get PhantomJS application version. Equals running "phantomjs -v" on the CLI.
getPhantomJsVersions ( ) : array Returns an array with PhantomJs version numbers.
getRequiredVersion ( Composer\Package\RootPackageInterface $package ) : mixed Returns the version for the given package either from the "require" or "require-dev" packages array.
getURL ( string $version ) : string Returns the URL of the PhantomJS distribution for the installing OS.
getVersion ( ) : string Returns the PhantomJS version number.
installPhantomJS ( Composer\Script\Event $event ) installPhantomJS is the main function of the install script.
setComposer ( Composer\Composer $composer ) : static
setIO ( Composer\IO\BaseIO $io ) : static

Method Details

__construct() public method

public __construct ( Composer\Composer $composer, Composer\IO\BaseIO $io )
$composer Composer\Composer
$io Composer\IO\BaseIO

__invoke() public method

public __invoke ( )

copyPhantomJsBinaryToBinFolder() public method

Takes different "folder structure" of the archives and different "binary file names" into account.
public copyPhantomJsBinaryToBinFolder ( string $targetDir, string $binDir ) : boolean
$targetDir string path to /vendor/jakoch/phantomjs
$binDir string path to binary folder
return boolean True, if file dropped. False, otherwise.

createComposerInMemoryPackage() public method

Returns a Composer Package, which was created in memory.
public createComposerInMemoryPackage ( string $targetDir, string $version ) : Composer\Package\Package
$targetDir string
$version string
return Composer\Package\Package

download() public method

The package to download is created on the fly. For downloading Composer\DownloadManager is used. Downloads are automatically retried with a lower version number, when the resource it not found (404).
public download ( string $targetDir, string $version ) : boolean
$targetDir string
$version string
return boolean

dropClassWithPathToInstalledBinary() public method

Usage: use PhantomInstaller\PhantomBinary; $bin = PhantomInstaller\PhantomBinary::BIN; $dir = PhantomInstaller\PhantomBinary::DIR; $bin = PhantomInstaller\PhantomBinary::getBin(); $dir = PhantomInstaller\PhantomBinary::getDir();
public dropClassWithPathToInstalledBinary ( string $binaryPath ) : boolean
$binaryPath string full path to binary
return boolean True, if file dropped. False, otherwise.

getBitSize() public method

Returns the Bit-Size.
public getBitSize ( ) : string
return string BitSize, e.g. 32, 64.

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

getComposer() public method

public getComposer ( ) : Composer\Composer
return Composer\Composer

getIO() public method

public getIO ( ) : Composer\IO\BaseIO
return Composer\IO\BaseIO

getLatestPhantomJsVersion() public method

Returns the latest PhantomJsVersion.
public getLatestPhantomJsVersion ( ) : string
return string Latest PhantomJs Version.

getLowerVersion() public method

Returns a lower version for a version number.
public getLowerVersion ( string $old_version ) : string
$old_version string Version number
return string Lower version number.

getOS() public method

Returns the Operating System.
public getOS ( ) : string
return string OS, e.g. macosx, windows, linux.

getPhantomJsBinary() public method

Get path to PhantomJS binary.
public getPhantomJsBinary ( string $binDir ) : string | boolean
$binDir string
return string | boolean Returns false, if file not found, else filepath.

getPhantomJsVersionFromBinary() public method

Get PhantomJS application version. Equals running "phantomjs -v" on the CLI.
public getPhantomJsVersionFromBinary ( string $pathToBinary ) : string
$pathToBinary string
return string PhantomJS Version

getPhantomJsVersions() public method

Returns an array with PhantomJs version numbers.
public getPhantomJsVersions ( ) : array
return array PhantomJs version numbers

getRequiredVersion() public method

Returns the version for the given package either from the "require" or "require-dev" packages array.
public getRequiredVersion ( Composer\Package\RootPackageInterface $package ) : mixed
$package Composer\Package\RootPackageInterface
return mixed

getURL() public method

Returns the URL of the PhantomJS distribution for the installing OS.
public getURL ( string $version ) : string
$version string
return string Download URL

getVersion() public method

Firstly, we search for a version number in the local repository, secondly, in the root package. A version specification of "dev-master#" is disallowed.
public getVersion ( ) : string
return string $version Version

installPhantomJS() public static method

It installs PhantomJs into the defined /bin folder, taking operating system dependend archives into account. You need to invoke it from the scripts section of your "composer.json" file as "post-install-cmd" or "post-update-cmd".
public static installPhantomJS ( Composer\Script\Event $event )
$event Composer\Script\Event

setComposer() public method

public setComposer ( Composer\Composer $composer ) : static
$composer Composer\Composer
return static

setIO() public method

public setIO ( Composer\IO\BaseIO $io ) : static
$io Composer\IO\BaseIO
return static

Property Details

$composer protected_oe property

protected Composer,Composer $composer
return Composer\Composer

$io protected_oe property

protected BaseIO,Composer\IO $io
return Composer\IO\BaseIO