<div class=\"panel\">
<!-- Collect the nav links, forms, and other content for toggling -->
<div class=\"collapse navbar-collapse\" id=\"navbar-collapse-main\">
<ul class=\"nav navbar-nav\">
</div>
<p id=\"version-notice\">You are currently viewing version <span>4.0</span> documentation.</p>
<div class=\"col-sm-9 col-sm-offset-3\">
Introduction
PHP PhantomJS is a flexible PHP library to load pages through the PhantomJS headless browser and return the page response. It is handy for testing websites that demand javascript support and also supports screen captures and PDF output.
Feature List
Load webpages through the PhantomJS headless browser
View detailed response data including page content, headers, status
code etc.
Handle redirects
View javascript console errors
View detailed PhantomJS debuged information
Save screen captures to local disk
Output web pages to PDF document
Set viewport size
Set fixed header and footer for PDF output
Define screen capture x, y, width and height parameters
Delay page rendering for a specified time
Delay page rendering until page resources are fully loaded
Execute PhantomJS with command line options
Easily build and run custom PhantomJS scripts
Prerequisites
PHP PhantomJS requires PHP 5.4.0 or greater to run.
Installation
It is recommended that you use Composer to install PHP PhantomJS. First, add the following to your project’s composer.json file:
This will ensure the latest version of PhantomJS is installed for your system, in your bin folder. If you haven’t defined your bin folder in your composer.json, add the path:
#composer.json\"config\":{\"bin-dir\":\"bin\"}
Finally, install PHP PhantomJS from the root of your project:
If you would like to use another installation method or would like to see more detailed installation instructions, see the installation documentation.
Important
By default the PhantomJS library will look for the PhantomJS executable in the bin folder relative to where your script is running ~/bin/phantomjs. If the executable cannot be found or if the path to your PhantomJS executable differs from the default location, for example you have installed PhantomJS globally, you will need to define the path to your PhantomJS executable manually.