jakoch / phantomjs-installer

A Composer package which installs the PhantomJS binary (Linux, Windows, Mac) into `/bin` of your project.

Maintainers

composer install phantomjs

github.com/jakoch/phantomjs-installer

Installs : 4 848 047

Dependents : 83

Suggesters : 4

Security : 0

Stars : 149

Watchers : 12

Open Issues : 0

Type: custom-installer

Add Maintainer

Remove maintainer.

Username jakoch

  • php: >5.3
  • ext-openssl : *

Requires (Dev)

  • composer/composer : ^1.2
  • phpunit/phpunit : ^8

MIT 4ba2bc95dd442fd4ad9159c45882aa372bbb51cd

  • Jens-André Koch <jakoch .woop @web.de>

headless phantomjs binaries

This package is auto-updated.

Last update: 2024-02-12 19:48:22 UTC

Latest Stable Version

A Composer package which installs the PhantomJS binary (Linux, Windows, Mac) into /bin of your project.

Table of Contents

Installation.

  • How to require a specific version of PhantomJS?

How does this work internally?

  • How to access the binary easily by using PhantomInstaller\PhantomBinary?
  • How to package for another platform by overriding platform requirements?
  • How to use a Mirror or a custom CDN URL for downloading?

To install PhantomJS as a local, per-project dependency to your project, simply add a dependency on jakoch/phantomjs-installer to your project's composer.json file.

For a development dependency, change require to require-dev .

The default download source used is: https://bitbucket.org/ariya/phantomjs/downloads/ You might change it by setting a custom CDN URL, which is explained in the section " Downloading from a mirror ".

By setting the Composer configuration directive bin-dir , the vendor binaries will be installed into the defined folder. Important! Composer will install the binaries into vendor\bin by default.

The scripts section is necessary, because currently Composer does not pass events to the handler scripts of dependencies. If you leave it away, you might execute the installer manually.

Now, assuming that the scripts section is set up as required, the PhantomJS binary will be installed into the /bin folder and updated alongside the project's Composer dependencies.

How to require specific versions of PhantomJS?

The environment and server variable PHANTOMJS_VERSION enables you specify the version requirement at the time of packaging.

You can also set the phantomjs-version in the extra section of your composer.json :

The search order for the version is 1) $_ENV, 2) $_SERVER, 3) composer.json (extra section), 4) fallback to v2.1.1 (hardcoded latest version).

  • Fetching the PhantomJS Installer

In your composer.json you require the package "phantomjs-installer". The package is fetched by composer and stored into ./vendor/jakoch/phantomjs-installer . It contains only one file the PhantomInstaller\\Installer .

  • Platform-specific download of PhantomJS

The PhantomInstaller\\Installer is run as a "post-install-cmd". That's why you need the "scripts" section in your "composer.json". The installer creates a new composer in-memory package "phantomjs", detects your OS and downloads the correct Phantom version to the folder ./vendor/jakoch/phantomjs . All PhantomJS files reside there, especially the examples .

  • Installation into /bin folder

The binary is then copied from ./vendor/jakoch/phantomjs to your composer configured bin-dir folder.

  • Generation of PhantomBinary

The installer generates a PHP file PhantomInstaller\\PhantomBinary and inserts the path to the binary.

PhantomBinary

To access the binary and its folder easily, the class PhantomBinary is created automatically during installation.

The class defines the constants BIN and DIR :

  • BIN is the full-path to the PhantomJS binary file, e.g. /your_project/bin/phantomjs
  • DIR is the folder of the binary, e.g. /your_project/bin

Both constants are also accessible via their getter-methods getBin() and getDir() .

This feature is similar to location.js of the phantomjs module for Node.

Override platform requirements

The environment and server variables PHANTOMJS_PLATFORM and PHANTOMJS_BITSIZE enable you to override the platform requirements at the time of packaging. This decouples the packaging system from the target system. It allows to package on Linux for MacOSX or on Windows for Linux.

Possible values for

  • PHANTOMJS_PLATFORM are: macosx , windows , linux .
  • PHANTOMJS_BITSIZE are: 32 or 64 .

Downloading from a mirror

You can override the default download location of the PhantomJS binary file by setting it in one of these locations. Listed in order of precedence (highest first):

  • The environment variable PHANTOMJS_CDNURL
  • The server variable PHANTOMJS_CDNURL
  • In your composer.json by using $['extra']['jakoch/phantomjs-installer']['cdnurl'] :

Default Download Location

The default download location is Bitbucket: https://api.bitbucket.org/2.0/repositories/ariya/phantomjs/downloads/ . You don't need to set it explicitly. It's used, when PHANTOMJS_CDNURL is not set.

You might use one of the following mirror URLs as a value for PHANTOMJS_CDNURL :

  • https://cnpmjs.org/downloads/ - USA, San Mateo (47.88.189.193)
  • https://npm.taobao.org/mirrors/phantomjs/ - China, Hangzhou (114.55.80.225)
  • https://github.com/Medium/phantomjs/ - USA, San Francisco (192.30.253.113)

This list of mirrors is not complete. If you know another mirror, please don't hesitate to add it here.

The mirror URLs are also not hardcoded, except for the Github URL. This enables you to point to any PhantomJS mirror or download folder you like. For instance, you could point to the URL of the download folder of your company, where the binaries are stored: PHANTOMJS_CDNURL=https://cdn.company.com/downloads/phantomjs/ .

Automatic download retrying with version lowering on 404

In case downloading an archive fails with HttpStatusCode 404 (resource not found), the downloader will automatically lower the version to the next available version and retry. The number of retries is determined by the number of hardcoded PhantomJS versions in getPhantomJSVersions() . This feature was added, because of the problems with v2.0.0 not being available for all platforms (see issue #25).

This package has been deprecated

Author message:

  • 8 Dependencies
  • 517 Dependents
  • 81 Versions

An NPM installer for PhantomJS , headless webkit with JS API.

Pre-2.0, this package was published to NPM as phantomjs . We changed the name to phantomjs-prebuilt at the request of PhantomJS team.

Please update your package references from phantomjs to phantomjs-prebuilt

Building and Installing

Or grab the source and

What this installer is really doing is just grabbing a particular "blessed" (by this module) version of Phantom. As new versions of Phantom are released and vetted, this module will be updated accordingly.

And npm will install a link to the binary in node_modules/.bin as it is wont to do.

Running via node

The package exports a path string that contains the path to the phantomjs binary/executable.

Below is an example of using this package via node.

The major and minor number tracks the version of PhantomJS that will be installed. The patch number is incremented when there is either an installer update or a patch build of the phantom binary.

Deciding Where To Get PhantomJS

By default, this package will download phantomjs from our releases . This should work fine for most people.

Downloading from a custom URL

If github is down, or the Great Firewall is blocking github, you may need to use a different download mirror. To set a mirror, set npm config property phantomjs_cdnurl .

Alternatives include https://bitbucket.org/ariya/phantomjs/downloads (the official download site) and http://cnpmjs.org/downloads .

Or add property into your .npmrc file (https://www.npmjs.org/doc/files/npmrc.html)

Another option is to use PATH variable PHANTOMJS_CDNURL .

Using PhantomJS from disk

If you plan to install phantomjs many times on a single machine, you can install the phantomjs binary on PATH. The installer will automatically detect and use that for non-global installs.

Cross-Platform Repositories

PhantomJS needs to be compiled separately for each platform. This installer finds a prebuilt binary for your operating system, and downloads it.

If you check your dependencies into git, and work on a cross-platform team, then you need to tell NPM to rebuild any platform-specific dependencies. Run

as part of your build process. This problem is not specific to PhantomJS, and this solution will work for any NodeJS package with native or platform-specific code.

If you know in advance that you want to install PhantomJS for a specific architecture, you can set the environment variables: PHANTOMJS_PLATFORM (to set target platform) and PHANTOMJS_ARCH (to set target arch), where platform and arch are valid values for process.platform and process.arch .

A Note on PhantomJS

PhantomJS is not a library for NodeJS. It's a separate environment and code written for node is unlikely to be compatible. In particular PhantomJS does not expose a Common JS package loader.

This is an NPM wrapper and can be used to conveniently make Phantom available It is not a Node JS wrapper.

I have had reasonable experiences writing standalone Phantom scripts which I then drive from within a node program by spawning phantom in a child process.

Read the PhantomJS FAQ for more details: http://phantomjs.org/faq.html

An extra note on Linux usage, from the PhantomJS download page:

There is no requirement to install Qt, WebKit, or any other libraries. It however still relies on Fontconfig (the package fontconfig or libfontconfig, depending on the distribution).

Troubleshooting

Installation fails with spawn enoent.

This is NPM's way of telling you that it was not able to start a process. It usually means:

  • node is not on your PATH, or otherwise not correctly installed.
  • tar is not on your PATH. This package expects tar on your PATH on Linux-based platforms.

Check your specific error message for more information.

Installation fails with Error: EPERM or operation not permitted or permission denied

This error means that NPM was not able to install phantomjs to the file system. There are three major reasons why this could happen:

  • You don't have write access to the installation directory.
  • The permissions in the NPM cache got messed up, and you need to run npm cache clean to fix them.
  • You have over-zealous anti-virus software installed, and it's blocking file system writes.

Installation fails with Error: read ECONNRESET or Error: connect ETIMEDOUT

This error means that something went wrong with your internet connection, and the installer was not able to download the PhantomJS binary for your platform. Please try again.

I tried again, but I get ECONNRESET or ETIMEDOUT consistently.

Do you live in China, or a country with an authoritarian government? We've seen problems where the GFW or local ISP blocks github, preventing the installer from downloading the binary.

Try visiting the download page manually. If that page is blocked, you can try using a different CDN with the PHANTOMJS_CDNURL env variable described above.

I am behind a corporate proxy that uses self-signed SSL certificates to intercept encrypted traffic.

You can tell NPM and the PhantomJS installer to skip validation of ssl keys with NPM's strict-ssl setting:

WARNING: Turning off strict-ssl leaves you vulnerable to attackers reading your encrypted traffic, so run this at your own risk!

I tried everything, but my network is b0rked. What do I do?

If you install PhantomJS manually, and put it on PATH, the installer will try to use the manually-installed binaries.

I'm on Debian or Ubuntu, and the installer failed because it couldn't find node

Some Linux distros tried to rename node to nodejs due to a package conflict. This is a non-portable change, and we do not try to support this. The official documentation recommends that you run apt-get install nodejs-legacy to symlink node to nodejs on those platforms, or many NodeJS programs won't work properly.

Contributing

Questions, comments, bug reports, and pull requests are all welcome. Submit them at the project on GitHub . If you haven't contributed to an Medium project before please head over to the Open Source Project and fill out an OCLA (it should be pretty painless).

Bug reports that include steps-to-reproduce (including code) are the best. Even better, make them in the form of pull requests.

Dan Pupius ( personal website ) and Nick Santos , supported by A Medium Corporation .

Copyright 2012 A Medium Corporation .

Licensed under the Apache License, Version 2.0. See the top-level file LICENSE.txt and (http://www.apache.org/licenses/LICENSE-2.0).

Package Sidebar

npm i phantomjs

Git github.com/Medium/phantomjs

github.com/Medium/phantomjs

Downloads Weekly Downloads

Last publish.

8 years ago

Collaborators

mediumeng

PhantomJS

  • Source Code

Related Projects

In the family.

The following projects are based on PhantomJS. They provide extra functionalities.

Casper.js is useful to build scripted navigation and testing.

Chutzpah is a JavaScript test runner which runs from Visual Studio, the command line, TeamCity or your favorite CI server. It can run directly on JavaScript, CoffeeScript and TypeScript files and has built in code coverage support.

Ghostbuster simplifies the testing setup with more convenient wrappers.

GhostDriver implements Remote WebDriver Wire protocol for PhantomJS. Although it is developed separately, it has been a part of PhantomJS core since PhantomJS 1.8.

GhostJS simplifies test logic with ES7 async functions and removes the need for callbacks.

Lotte adds jQuery-like methods, chaining, and more assertion logic.

PhearJS a supervisor and API for PhantomJS written in NodeJS.

  • Poltergeist is a driver for Capybara so you can run your Capybara tests using PhantomJS.

GastonJS is a driver for PHP Mink so you can run your Behat or Mink tests using PhantomJS.

pjscrape combines PhantomJS with jQuery as a command-line scraping tool.

WebSpecter is a BDD-style acceptance test framework for web applications.

conjure lets you write CasperJS tests in BDD-style modules and run them with variable concurrency. Also provides additional stack tracing, helpers and module bootstrapping.

  • PhantomJS Google Charts lets you capture the svg data for charts produced by Google’s JSAPI and use it server side. Examples would be to inject the charts into a PDF or to convert it to a JPG.

Screenshot Utilities

Several page capture projects utilizing PhantomJS:

  • capturejs (Node.js)
  • DeckTape a CLI to capture screenshots and export high-quality PDF documents of slides from any HTML presentation frameworks like impress.js, reveal.js, …
  • pageres - get screenshots of website(s) in few different resolutions to make sure they are responsive (Node.js)
  • phantomjs-screenshots , a system for running screenshot tasks defined in JSON format (Node.js)
  • manet (Node.js)
  • screenshot-app (Node.js)
  • screenshot-as-a-service (Node.js)
  • screenshot-service a pure phantomJS project to capture screenshot of any page with various configuration options
  • screenshot (Dancer)
  • screenshot-webservice (Play2)
  • pyshotx a screenshot server using multiple phantomJS processes and queues (Gevent, Redis)
  • htmlshots a screenshot server based on the WebServer module that accepts both URLs and HTML file uploads
  • node-webshot
  • pageres , a command-line tool and Node.js module to get screenshots of website(s) in few different resolutions to make sure they are responsive (uses Node.js)
  • django-screamshot
  • PHP Screen a PHP interface to Phantom JS to make website screenshots.
  • grabshot , a simple Sinatra-based API to take screenshots and respond asynchronously to a provided callback URL.

basset command-line website performance sniffer.

Compass Magick is a dynamic image generation for Compass using (among others) PhantomJS.

Confess is small script library that uses PhantomJS to headlessly analyze web pages for the purposes of creating a cache manifest file.

GhostStory is a collection of Cucumber steps for automated CSS testing with SpookyJS, CasperJS, PhantomJS, PhantomCSS and Node.JS.

Grover is a wrapper to automatically run YUI Test based tests.

Grunt is a task-based command line build tool for JavaScript projects using PhantomJS for unit test automation.

Guard PhantomJS automatically runs PhantomJS using Guard.

phridge provides an easy way to run scripts in PhantomJS and return results back to node.js.

phantomjs-node provides PhantomJS bridge for Node.js applications.

node-phantom is a bridge between PhantomJS and Node.js.

phantom-proxy provides a proxy interface for PhantomJS which runs inside of node.

phantomas is a web-performance metrics and hints generation tool.

PhantomCSS enables automated visual regression testing.

PhantomFlow provides a syntax for describing user flows as tests which can then be visualized as an interactive tree graph. Built on CasperJS, integrates with PhantomCSS and uses D3.js for visualization.

phantomjs-installer provides a PHP Composer package which installs the PhantomJS binary (Linux, Windows, Mac) into the /bin folder of your project.

phantomjs-maven-plugin is a Maven plugin with the primary purpose of installing the PhantomJS binary and providing a property containing the location of the binary for use within a build. It also provides a goal for executing PhantomJS scripts.

“phantomjs” is a Node.js module to download/install PhantomJS and provide its executable path (and that’s all). Used by Grunt in grunt-lib-phantomjs for higher-level use in grunt-contrib-qunit , etc.

PhantomLint uses PhantomJS to run JSLint on JavaScript application code.

PhantomXHR isolates UI from server API for fast automated UI testing.

PHP PhantomJs provides a PHP interface for PhantomJS.

shortcut.io uses PhantomJS to generate the screenshot of the bookmarked web sites.

Slippy uses PhantomJS to convert HTML presentations into PDFs that can be e.g. uploaded to SlideShare.

SpookyJS drives CasperJS from Node.js over HTTP or stdio.

Yeoman is a robust and opinionated client-side stack, comprised of tools and frameworks that can help developers quickly build beautiful web applications. It uses PhantomJS (via Grunt) as a basis for headless tests.

Documentation

  • Get Started
  • D Inter Process Communication
  • D Command Line Interface
  • D Troubleshooting
  • D Best Practices
  • D Tips and Tricks
  • D Supported Web Standards
  • D Who's using PhantomJS?
  • D Related Projects
  • D Contributing
  • D Test Suite
  • D Release Preparation
  • D Crash Reporting
  • D Bug Reporting

© Copyright 2010-2020 Ariya Hidayat — Homepage design by Maurice Svay — Documentation design by Jamie Mason .

Composer and phantomjs (for PDF and Excel reports on Analytics)

Despite the directions in the google drive they don’t actually work because composer wants a composer.json file which doesn’t get created when we do: $ brew install composer . All it does is creates a composer.lock file. And then when we try to use composer to install all of our projects dependencies which it would usually get from our composer.json file (much like npm’s package.json file) it can’t find any! Well, we can just create one and copy/paste our dependencies into it and then all will, once again, be right in the world.

Install composer with brew: $ brew install composer You can check the install with: $ composer -V

create a composer.json file within project directory ( ~/Sites/project/ ): $ vim composer.json

I went into to github and copy/pasted the composer.lock contents into our new composer.lock file. (use :wq to exit vim. :D )

Now, we can run $ composer install which will go through and install all the dependencies. Now we’ll have a /bin/ directory (before we didnt). cd into it and then give phantomjs read/write priviliges with. $ chmod 777 phantomjs

go and get your reporting on.

Phantomjs Installer Save

A Composer Package which installs the PhantomJS binary (Linux, Windows, Mac) into /bin of your project.

phantomjs-installer

Latest Stable Version

A Composer package which installs the PhantomJS binary (Linux, Windows, Mac) into /bin of your project.

Table of Contents

Installation.

  • How to require a specific version of PhantomJS?

How does this work internally?

  • How to access the binary easily by using PhantomInstaller\PhantomBinary?
  • How to package for another platform by overriding platform requirements?
  • How to use a Mirror or a custom CDN URL for downloading?

To install PhantomJS as a local, per-project dependency to your project, simply add a dependency on jakoch/phantomjs-installer to your project's composer.json file.

For a development dependency, change require to require-dev .

The default download source used is: https://bitbucket.org/ariya/phantomjs/downloads/ You might change it by setting a custom CDN URL, which is explained in the section " Downloading from a mirror ".

By setting the Composer configuration directive bin-dir , the vendor binaries will be installed into the defined folder. Important! Composer will install the binaries into vendor\bin by default.

The scripts section is necessary, because currently Composer does not pass events to the handler scripts of dependencies. If you leave it away, you might execute the installer manually.

Now, assuming that the scripts section is set up as required, the PhantomJS binary will be installed into the /bin folder and updated alongside the project's Composer dependencies.

How to require specific versions of PhantomJS?

The environment and server variable PHANTOMJS_VERSION enables you specify the version requirement at the time of packaging.

You can also set the phantomjs-version in the extra section of your composer.json :

The search order for the version is 1) $_ENV, 2) $_SERVER, 3) composer.json (extra section), 4) fallback to v2.1.1 (hardcoded latest version).

  • Fetching the PhantomJS Installer

In your composer.json you require the package "phantomjs-installer". The package is fetched by composer and stored into ./vendor/jakoch/phantomjs-installer . It contains only one file the PhantomInstaller\\Installer .

  • Platform-specific download of PhantomJS

The PhantomInstaller\\Installer is run as a "post-install-cmd". That's why you need the "scripts" section in your "composer.json". The installer creates a new composer in-memory package "phantomjs", detects your OS and downloads the correct Phantom version to the folder ./vendor/jakoch/phantomjs . All PhantomJS files reside there, especially the examples .

  • Installation into /bin folder

The binary is then copied from ./vendor/jakoch/phantomjs to your composer configured bin-dir folder.

  • Generation of PhantomBinary

The installer generates a PHP file PhantomInstaller\\PhantomBinary and inserts the path to the binary.

PhantomBinary

To access the binary and its folder easily, the class PhantomBinary is created automatically during installation.

The class defines the constants BIN and DIR :

  • BIN is the full-path to the PhantomJS binary file, e.g. /your_project/bin/phantomjs
  • DIR is the folder of the binary, e.g. /your_project/bin

Both constants are also accessible via their getter-methods getBin() and getDir() .

This feature is similar to location.js of the phantomjs module for Node.

Override platform requirements

The environment and server variables PHANTOMJS_PLATFORM and PHANTOMJS_BITSIZE enable you to override the platform requirements at the time of packaging. This decouples the packaging system from the target system. It allows to package on Linux for MacOSX or on Windows for Linux.

Possible values for

  • PHANTOMJS_PLATFORM are: macosx , windows , linux .
  • PHANTOMJS_BITSIZE are: 32 or 64 .

Downloading from a mirror

You can override the default download location of the PhantomJS binary file by setting it in one of these locations. Listed in order of precedence (highest first):

  • The environment variable PHANTOMJS_CDNURL
  • The server variable PHANTOMJS_CDNURL
  • In your composer.json by using $['extra']['jakoch/phantomjs-installer']['cdnurl'] :

Default Download Location

The default download location is Bitbucket: https://api.bitbucket.org/2.0/repositories/ariya/phantomjs/downloads/ . You don't need to set it explicitly. It's used, when PHANTOMJS_CDNURL is not set.

You might use one of the following mirror URLs as a value for PHANTOMJS_CDNURL :

  • https://cnpmjs.org/downloads/ - USA, San Mateo (47.88.189.193)
  • https://npm.taobao.org/mirrors/phantomjs/ - China, Hangzhou (114.55.80.225)
  • https://github.com/Medium/phantomjs/ - USA, San Francisco (192.30.253.113)

This list of mirrors is not complete. If you know another mirror, please don't hesitate to add it here.

The mirror URLs are also not hardcoded, except for the Github URL. This enables you to point to any PhantomJS mirror or download folder you like. For instance, you could point to the URL of the download folder of your company, where the binaries are stored: PHANTOMJS_CDNURL=https://cdn.company.com/downloads/phantomjs/ .

Automatic download retrying with version lowering on 404

In case downloading an archive fails with HttpStatusCode 404 (resource not found), the downloader will automatically lower the version to the next available version and retry. The number of retries is determined by the number of hardcoded PhantomJS versions in getPhantomJSVersions() . This feature was added, because of the problems with v2.0.0 not being available for all platforms (see issue #25).

Open Source Agenda Badge

From the blog.

composer install phantomjs

How to Choose Which Programming Language to Learn First?

Sign in to osa.

Search code, repositories, users, issues, pull requests...

Provide feedback.

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly.

To see all available qualifiers, see our documentation .

  • Notifications

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement . We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

composer update/install fails #97

@pablomoreno61

pablomoreno61 commented Apr 15, 2016

@SoldierCorp

SoldierCorp commented Apr 17, 2016

Sorry, something went wrong.

@ghost

ghost commented Apr 19, 2016

@jonnnnyw

jonnnnyw commented Apr 20, 2016 • edited

@gorillaedan

gorillaedan commented Apr 20, 2016

Jonnnnyw commented apr 20, 2016, ghost commented apr 20, 2016, pablomoreno61 commented apr 21, 2016.

No branches or pull requests

@pablomoreno61

  • 4.0 version
  • 3.0 version
  • Introduction
  • Installation
  • Advanced Usage

Troubleshooting

  • Top of Page

composer install phantomjs

PHP PhantomJs

You are currently viewing version 3.0 documentation.

It’s not installing anything to my bin directory

I am getting a invalidexecutableexception when making a request, i am getting a notwritableexception when making a request, why do i need the phantomloader file, why am i getting a status code of 0 in the response, it’s not saving my screenshots, can i set the screenshot size, can i set the viewport size, how do i debug a request, i am getting syntaxerror: parse error in the debug log.

When installing via composer, as outlined in the installation guide , it is recommended that you define the location of the bin folder for your project. This can be done by adding the following to your composer.json file:

You need to make sure that this directory exists and is writable before you install your composer depedencies.

Once you have defined your bin folder in your composer.json file, run composer install from the root of your project:

This should install 2 files to your bin folder: phantomjs and phantomloader . If you do not have these 2 files in your bin folder then check that the folder is writable and run composer install again.

Note If you do not define a bin directory in your composer.json file then the default install location will be vendor/bin/ . If you choose to not set a bin folder path then you will need to make sure that this path is set in the client by calling $client->setBinDir('vendor/bin'); before making a request.

If you have installed via composer, as outlined in the installation guide , then you should have 2 files installed in either the bin or vendor/bin/ directory, in the root of your project. These files are called phantomjs and phantomloader .

Check that these files exist and are executable by your application. If they do not exist, see It’s not installing anything to my bin directory .

If the PHP PhantomJS library cannot locate either of these files then it will throw a InvalidExecutableException . The message in the exception should tell you which one it can’t execute. If both of these files exist and they are executable by your application, you may need to set the path to the directory that these files live in before making a request:

When making a request, the PHP PhantomJS library compiles a temporary script file to your system’s tmp folder. The location of this folder is determined through the use of the sys_get_temp_dir() function. If this directory is not writable by your application then you will receive this exception.

A proxy loader file is used get around a quirk that PhantomJS has when it encounters a syntax error in a script file. By default, if PhantomJS encounters a syntax error when loading a script file it will not exit execution. This means that PHP PhantomJS will continue to wait for a response from PhantomJS until PHP reaches its script execution timeout period. This also means you won’t get any debug information informing you that the PhantomJS script has a syntax error.

To get around this, script files are loaded through a loader script. This handles the event of a syntax error and ensures that PhantomJS exits when an error is encountered.

The phantomloader file is required in order for the PHP PhantomJS library to run so please make sure that it was installed to your bin folder and is readable by your application.

Another reason for getting this exception is when you are trying to save screenshots. See It’s not saving my screenshots .

A status code of 0 in the response object generally means the request did not complete successfully. This could mean that the URL you are requesting did not return a response or that something happened when making the request that did not raise an error in the PHP PhantomJS library.

Becuase and exception was not thrown, chances are the issue is with PhantomJS itself or at the endpoint you are calling.

One possible reason for this is that your request has timed out before a response was returned from the endpoint that you are requesting. Depending on what you are requesting, some websites seem to take a while to return a response. An example of this is myspace.com which, at the time of writing this, takes a considerable amount of time resolve through PhantomJS.

To work around this you can try increasing the timeout period in the PHP PhantomJS client:

If you are still having a problem then you should enable debugging, before you make the request, and check the debug log. This contains a dump of information from PhantomJS which could help to track down why you are not getting a response.

You can also try running a test script through your PhantomJS executable, from the command line, to see if you get a valid response back. Save the following script somewhere:

And then, assuming you have saved the script above to test-script.js in the root of your project and your PhantomJS executable is located at bin/phantomjs , run the following:

You should see an output of the response from PhantomJS:

If you don’t see success followed by a JSON encoded response object then there is something the with the URL you are requesting or your PhantomJS executable. Try reinstalling PhantomJS. If you see fail instead of success , chances are the URL you are requesting is invalid or not resolving.

When making a capture request you need to make sure that you are setting the file location that you want the screenshot saved to, including the filename:

The file itself does not need to exist but the parent directory must exist and be writable by your application. Check that your application has permissions to write files to the directory you are setting for your screen captures.

Yes, you can set the width and height of your capture along with the x and y coordinates of where the capture should start from:

Yes, you can set the viewport dimensions on both regular and capture requests:

By setting the debug flag to true on the client, you can get a dump of information output from PhantomJS along with some info events added by the PHP PhantomJS library:

You can also get any javacript console errors along with a stack trace from the URL you are calling, in the response object:

You will only get this error if the script file that is being run by PhantomJS has a syntax error. If you are writing your own custom scripts then try setting the debug flag which should print some more detailed information in the debug log. Also check that you aren’t setting any parameters to null in your request object as this could be causing a javascript error due to javascript variables being set to nothing e.g. var width = , .

  • Advanced Usage →

Download Composer Latest: v2.7.1

To quickly install Composer in the current directory, run the following script in your terminal. To automate the installation, use the guide on installing Composer programmatically .

This installer script will simply check some php.ini settings, warn you if they are set incorrectly, and then download the latest composer.phar in the current directory. The 4 lines above will, in order:

  • Download the installer to the current directory
  • Verify the installer SHA-384, which you can also cross-check here
  • Run the installer
  • Remove the installer

Most likely, you want to put the composer.phar into a directory on your PATH, so you can simply call composer from any directory ( Global install ), using for example:

For details, see the instructions on how to install Composer globally .

WARNING: Please do not redistribute the install code. It will change with every version of the installer. Instead, please link to this page or check how to install Composer programmatically .

Notable Installer Options

--install-dir.

You can install composer to a specific directory by using the --install-dir option and providing a target directory. Example:

You can specify the filename (default: composer.phar ) using the --filename option. Example:

You can install composer to a specific release by using the --version option and providing a target release. Example:

--preview, --snapshot, --1 (EOL), --2, --2.2 (LTS)

Select a specific version channel instead of the default latest stable. See "Download channels" below for more details. Example:

The installer provides more options for specific environments, use the --help option to see all of them.

Download channels

By default the installer and composer self-update will download the latest stable version only. You may select a different download channel though. If you would like to help test pre-release versions you can use the --preview flag on either the installer or self-update. For snapshot builds, which are done from the latest Composer commit, you can use the --snapshot flag. To programmatically install specific major versions you can use the --1 or --2 flag. To select the latest 2.2 LTS you can use --2.2 .

Manual Download

If you prefer to download the phar manually, here are the available versions:

Latest Stable ( sha256 / sha256sum / asc ) for PHP 7.2+ users Latest Preview (alpha/beta/RC) ( sha256 / sha256sum / asc ) Latest Snapshot ( sha256 / sha256sum ) Latest 1.x ( sha256 / sha256sum ) Latest 2.x ( sha256 / sha256sum / asc ) Latest 2.2.x LTS ( sha256 / sha256sum / asc ) for PHP 5.3 to 7.1 users

IMAGES

  1. How to install phantomjs on RHEL 8 / CentOS 8

    composer install phantomjs

  2. Install PhantomJS on Windows

    composer install phantomjs

  3. How to Install PhantomJS

    composer install phantomjs

  4. How To Install PhantomJS On Kali Linux

    composer install phantomjs

  5. Tutorial Cara Download dan Install Composer

    composer install phantomjs

  6. How to Install PhantomJS on Windows

    composer install phantomjs

VIDEO

  1. how to install composer

  2. PhantomJs Part 1 Intro to PhantomJs Tutorials

  3. Introduction to composer

  4. Tutorial Composer : Cara install composer di linux ubuntu

  5. Install Laravel 10 using composer

  6. How to create a Laravel project and Change PHP version (Windows)

COMMENTS

  1. How to install PHP PhantomJS require packages

    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? php phpunit phantomjs composer-php Share Improve this question Follow

  2. Installation

    Installing via Composer Custom Installation Installing from tarball Prerequisites PHP PhantomJS requires PHP 5.4.0 or greater to run. Installing via Composer Install Composer for your project: #bash $ curl -s http://getcomposer.org/installer | php Create a composer.json file in the root of your project:

  3. GitHub

    Installation To install PhantomJS as a local, per-project dependency to your project, simply add a dependency on jakoch/phantomjs-installer to your project's composer.json file.

  4. PHP PhantomJS

    First, add the following to your project's composer.json file: #composer.json "scripts": { "post-install-cmd": [ "PhantomInstaller\\Installer::installPhantomJS" ], "post-update-cmd": [ "PhantomInstaller\\Installer::installPhantomJS" ] } This will ensure the latest version of PhantomJS is installed for your system, in your bin folder.

  5. jakoch/phantomjs-installer

    Details github.com/jakoch/phantomjs-installer Source Issues Installs : 4 844 926 Dependents : 83 Suggesters : 4 Security : 0 Stars : 149 Watchers : 12 Forks : 43 Open Issues : 0 Type: custom-installer 3.0.1 2021-09-03 18:54 UTC Requires php: >5.3 ext-bz2: * ext-openssl: * Requires (Dev) composer/composer: ^1.2 phpunit/phpunit: ^8 Suggests None

  6. PhantomJS

    CPU: 1.8 GHz, 4 cores or more. PhantomJS is still a web browser, albeit headless. Thus, building it from source takes a long time (mainly due to thousands of files in the WebKit module). Estimated build time for a 4-core system is 30 minutes. First, install the development packages of the following tools and libraries: GNU C++ compiler, bison ...

  7. Download PhantomJS

    Mac OS X Download phantomjs-2.1.1-macosx.zip (16.4 MB) and extract (unzip) the content. Note: For this static build, the binary is self-contained with no external dependency. It will run on a fresh install of OS X 10.7 (Lion) or later versions. There is no requirement to install Qt or any other libraries. Linux 64-bit

  8. Installation

    Once you have updated your bin location run composer install to install PhantomJS: #bash $ php composer.phar install This should install the correct PhantomJS executable for your system and the required phantomloader file to the bin locaiton you defined in your composer.json file. Now you need to tell the client where to find your bin folder:

  9. phantomjs

    If you install PhantomJS manually, and put it on PATH, the installer will try to use the manually-installed binaries. I'm on Debian or Ubuntu, and the installer failed because it couldn't find node. Some Linux distros tried to rename node to nodejs due to a package conflict. This is a non-portable change, and we do not try to support this.

  10. Related Projects

    phantomjs-installer provides a PHP Composer package which installs the PhantomJS binary (Linux, Windows, Mac) into the /bin folder of your project. phantomjs-maven-plugin is a Maven plugin with the primary purpose of installing the PhantomJS binary and providing a property containing the location of the binary for use within a build.

  11. Composer and phantomjs (for PDF and Excel reports on Analytics)

    Install composer with brew: $ brew install composer You can check the install with: $ composer -V create a composer.json file within project directory ( ~/Sites/project/ ): $ vim composer.json I went into to github and copy/pasted the contents into our new to exit vim. :D ) which will go through and install all the dependencies.

  12. GitHub

    There are few ways to install PhantomJS: ... Install binary through Composer. Simply pull in the anam/phantomjs-linux-x86-binary package to get the up-to-date PhantomJS binary for 64-bit Linux systems. composer require anam/phantomjs-linux-x86-binary. Integrations Laravel 4 and Laravel 5 integrations.

  13. Introduction

    It is recommended that you use Composer to install PHP PhantomJS. First, add the following to your project's composer.json file: #composer.json "scripts": { "post-install-cmd": [ "PhantomInstaller\\Installer::installPhantomJS" ], "post-update-cmd": [ "PhantomInstaller\\Installer::installPhantomJS" ] }

  14. Phantomjs Installer

    A Composer Package which installs the PhantomJS binary (Linux, Windows, Mac) into /bin of your project. ... Composer will install the binaries into vendor\bin by default. The scripts section is necessary, because currently Composer does not pass events to the handler scripts of dependencies. If you leave it away, you might execute the installer ...

  15. Installing PhantomJS on shared hosting (1and1)

    Using 1and1 linux shared hosting, I have installed: PHP Version 7.0.27 PHP PhantomJS 2.1.1. PHP PhantomJS all values are null. Whenever I make a request with:

  16. composer update/install fails · Issue #97 · jonnnnyw/php-phantomjs

    I just tried a clean install using the command you posted and it worked fine. Check that you have the following in your composer.json file, under the the require key: "jonnyw/php-phantomjs": "4.*" If you do and it's still not working then as a last resort you could delete your vendor folder and composer.lock file and run composer update.

  17. Troubleshooting

    This should install 2 files to your bin folder: phantomjs and phantomloader. If you do not have these 2 files in your bin folder then check that the folder is writable and run composer install again. Note If you do not define a bin directory in your composer.json file then the default install location will be vendor/bin/.

  18. Composer

    A Dependency Manager for PHP

  19. PHP PhantomJS not loading in class through Composer

    PHP PhantomJS not loading in class through Composer Ask Question Asked 8 years, 5 months ago Viewed Part of PHP Collective 7 I've followed the installation guide for PHP PhantomJS. When running a test script using PHP PhantomJS, I'm getting the error: PHP Fatal error: Class 'JonnyW\PhantomJs\Client' not found in ...

  20. composer: timeout on installing a dependencies package

    I am trying to install php phantomjs in my centos server using composer. It starts good but then it stops installing the package phantomjs. Any ideas on why it stops there? ... Composer installation fails : SSL handshake timeout. 2 Composer can't install. 1 ...

  21. Download

    Run the installer Remove the installer Most likely, you want to put the composer.phar into a directory on your PATH, so you can simply call composer from any directory ( Global install ), using for example: sudo mv composer.phar /usr/local/bin/composer For details, see the instructions on how to install Composer globally .