Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install PHP PhantomJS require packages

I'm trying to use PHP PhantomJS but it's require some package to run .. I'm composer in php and when I'm trying to install dependencies on root PHP PhantomJS

composer install

says

Loading composer repositories with package information
Installing dependencies (including require-dev)
Nothing to install or update
Generating autoload files

I'm confused ... anybody can help how install package that's need to run PHP PhantomJS script?

like image 671
MOB Avatar asked Nov 22 '13 13:11

MOB


2 Answers

If you downloaded it, you have everything you need without using Composer. Composer is for downloading this and other packages, but this is not the only way of getting packages. :)

Now the easiest way to use that package is to have a new clean empty directory and execute this line:

composer require jonnyw/php-phantomjs:2.*

Now magic happens, including the creation of a composer.json file, download of that package, creation of autoloading files, and then you are done.

With an otherwise empty directory you couldn't do very much, so in order to make use of that package (or others) inside your own code, go to the root directory of your code, and execute above line. The same things happen, and then you are pretty much done - apart from the fact that you need to include the autoloader file in your own code if you want to use that package.

like image 71
Sven Avatar answered Oct 21 '22 15:10

Sven


Install PhantomJS via Composer

Use the package "jakoch/phantomjs-installer".

It installs the PhantomJS binary for Linux, Windows or Mac into the /bin folder of your project.

  1. Simply add the following lines to your projects composer.json file:

     {
         "require": {
             "jakoch/phantomjs-installer": "3.0.0"
         },
         "scripts": {
             "post-install-cmd": [
                 "PhantomInstaller\\Installer::installPhantomJS"
             ],
             "post-update-cmd": [
                 "PhantomInstaller\\Installer::installPhantomJS"
             ]
         },
         "config": {
             "bin-dir": "bin"
         }
     }
    

    The version number determines which version of PhantomJS is fetched.

  2. Execute composer update or composer install

like image 34
Jens A. Koch Avatar answered Oct 21 '22 17:10

Jens A. Koch