PHP Class PhantomInstaller\Installer

Afficher le fichier Open project: jakoch/phantomjs-installer Class Usage Examples

Protected Properties

Свойство Type Description
$composer Composer\Composer
$io Composer\IO\BaseIO

Méthodes publiques

Méthode 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 méthode

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

__invoke() public méthode

public __invoke ( )

copyPhantomJsBinaryToBinFolder() public méthode

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
Résultat boolean True, if file dropped. False, otherwise.

createComposerInMemoryPackage() public méthode

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

download() public méthode

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
Résultat boolean

dropClassWithPathToInstalledBinary() public méthode

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
Résultat boolean True, if file dropped. False, otherwise.

getBitSize() public méthode

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

getCdnUrl() public méthode

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
Résultat string URL

getComposer() public méthode

public getComposer ( ) : Composer\Composer
Résultat Composer\Composer

getIO() public méthode

public getIO ( ) : Composer\IO\BaseIO
Résultat Composer\IO\BaseIO

getLatestPhantomJsVersion() public méthode

Returns the latest PhantomJsVersion.
public getLatestPhantomJsVersion ( ) : string
Résultat string Latest PhantomJs Version.

getLowerVersion() public méthode

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

getOS() public méthode

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

getPhantomJsBinary() public méthode

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

getPhantomJsVersionFromBinary() public méthode

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

getPhantomJsVersions() public méthode

Returns an array with PhantomJs version numbers.
public getPhantomJsVersions ( ) : array
Résultat array PhantomJs version numbers

getRequiredVersion() public méthode

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
Résultat mixed

getURL() public méthode

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

getVersion() public méthode

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
Résultat string $version Version

installPhantomJS() public static méthode

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 méthode

public setComposer ( Composer\Composer $composer ) : static
$composer Composer\Composer
Résultat static

setIO() public méthode

public setIO ( Composer\IO\BaseIO $io ) : static
$io Composer\IO\BaseIO
Résultat static

Property Details

$composer protected_oe property

protected Composer,Composer $composer
Résultat Composer\Composer

$io protected_oe property

protected BaseIO,Composer\IO $io
Résultat Composer\IO\BaseIO