public function dropClassWithPathToInstalledBinary($binaryPath)
    {
        $code = "<?php\n";
        $code .= "\n";
        $code .= "namespace PhantomInstaller;\n";
        $code .= "\n";
        $code .= "class PhantomBinary\n";
        $code .= "{\n";
        $code .= "    const BIN = '%binary%';\n";
        $code .= "    const DIR = '%binary_dir%';\n";
        $code .= "\n";
        $code .= "    public static function getBin() {\n";
        $code .= "        return self::BIN;\n";
        $code .= "    }\n";
        $code .= "\n";
        $code .= "    public static function getDir() {\n";
        $code .= "        return self::DIR;\n";
        $code .= "    }\n";
        $code .= "}\n";

        // binary      = full path to the binary
        // binary_dir  = the folder the binary resides in
        $fileContent = str_replace(
            array('%binary%', '%binary_dir%'),
            array($binaryPath, dirname($binaryPath)),
            $code
        );

        return (bool)file_put_contents(__DIR__ . '/PhantomBinary.php', $fileContent);
    }
public function dropClassWithPathToInstalledBinary($binaryPath)
    {
        $code = "<?php\n";
        $code .= "\n";
        $code .= "namespace PhantomInstaller;\n";
        $code .= "\n";
        $code .= "class PhantomBinary\n";
        $code .= "{\n";
        $code .= "    const BIN = '%binary%';\n";
        $code .= "    const DIR = '%binary_dir%';\n";
        $code .= "\n";
        $code .= "    public static function getBin() {\n";
        $code .= "        return self::BIN;\n";
        $code .= "    }\n";
        $code .= "\n";
        $code .= "    public static function getDir() {\n";
        $code .= "        return self::DIR;\n";
        $code .= "    }\n";
        $code .= "}\n";

        // binary      = full path to the binary
        // binary_dir  = the folder the binary resides in
        $fileContent = str_replace(
            array('%binary%', '%binary_dir%'),
            array($binaryPath, dirname($binaryPath)),
            $code
        );

        return (bool)file_put_contents(__DIR__ . '/PhantomBinary.php', $fileContent);
    }
public function dropClassWithPathToInstalledBinary ( $ binaryPath ) { $ code = "<?php\n" ; $ code .= "\n" ; $ code .= "namespace PhantomInstaller;\n" ; $ code .= "\n" ; $ code .= "class PhantomBinary\n" ; $ code .= "{\n" ; $ code .= "    const BIN = '%binary%';\n" ; $ code .= "    const DIR = '%binary_dir%';\n" ; $ code .= "\n" ; $ code .= "    public static function getBin() {\n" ; $ code .= "        return self::BIN;\n" ; $ code .= "    }\n" ; $ code .= "\n" ; $ code .= "    public static function getDir() {\n" ; $ code .= "        return self::DIR;\n" ; $ code .= "    }\n" ; $ code .= "}\n" ; // binary      = full path to the binary // binary_dir  = the folder the binary resides in $ fileContent = str_replace ( array ( '%binary%' , '%binary_dir%' ) , array ( $ binaryPath , dirname ( $ binaryPath ) ) , $ code ) ; return ( bool ) file_put_contents ( __DIR__ . '/PhantomBinary.php' , $ fileContent ) ; }
Drop php class with path to installed phantomjs binary for easier usage.

Usage:

use PhantomInstaller\PhantomBinary;

$bin = PhantomInstaller\PhantomBinary::BIN;
$dir = PhantomInstaller\PhantomBinary::DIR;

$bin = PhantomInstaller\PhantomBinary::getBin();
$dir = PhantomInstaller\PhantomBinary::getDir();

@param  string $binaryPath full path to binary

@return bool True, if file dropped. False, otherwise.
Drop php class with path to installed phantomjs binary for easier usage .