params.json 3.7 KB

1
  1. {"name":"php-phantomjs","tagline":"Execute PhantomJS commands through PHP","body":"Introduction\r\n=============\r\n\r\nPHP PhantomJS is a flexible PHP library to load pages through the PhantomJS \r\nheadless browser and return the page response. It is handy for testing\r\nwebsites that demand javascript support and also supports screen captures.\r\n\r\nFeature List\r\n---------------------\r\n\r\n* Load webpages through the PhantomJS headless browser\r\n* View detailed response data including page content, headers, status code etc.\r\n* Handle redirects\r\n* View javascript console errors\r\n* View detailed PhantomJS debuged information\r\n* Save screen captures to local disk \r\n* Define screen capture x, y, width and height parameters\r\n* Delay page rendering for a specified time\r\n* Execute PhantomJS with command line options\r\n* Easily build and run custom PhantomJS scripts\r\n\r\nPrerequisites\r\n---------------------\r\n\r\nPHP PhantomJS requires PHP **5.3.0** or greater to run.\r\n\r\nInstallation\r\n---------------------\r\n\r\nIt is recommended that you use Composer to install PHP PhantomJS. First, add the following to your project's composer.json file:\r\n\r\n```xml\r\n\"scripts\": {\r\n \"post-install-cmd\": [\r\n \"PhantomInstaller\\\\Installer::installPhantomJS\"\r\n ],\r\n \"post-update-cmd\": [\r\n \"PhantomInstaller\\\\Installer::installPhantomJS\"\r\n ]\r\n}\r\n```\r\n\r\nThis 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:\r\n\r\n```xml\r\n\"config\": {\r\n \"bin-dir\": \"bin\"\r\n}\r\n```\r\n\r\nFinally, install PHP PhantomJS from the root of your project:\r\n\r\n```xml\r\ncomposer require \"jonnyw/php-phantomjs:3.*\"\r\n```\r\n\r\nIf you would like to use another installation method or would like to see more detailed installation instructions, see the [installation](http://jonnnnyw.github.io/php-phantomjs/installation.html) documentation.\r\n\r\n\r\nBasic Usage\r\n---------------------\r\n\r\nThe following illustrates how to make a basic GET request and output the page content:\r\n\r\n```php\r\n<?php\r\n\r\nuse JonnyW\\PhantomJs\\Client;\r\n\r\n$client = Client::getInstance();\r\n\r\n/** \r\n * @see JonnyW\\PhantomJs\\Message\\Request \r\n **/\r\n$request = $client->getMessageFactory()\r\n ->createRequest('http://google.com', 'GET');\r\n\r\n/** \r\n * @see JonnyW\\PhantomJs\\Message\\Response \r\n **/\r\n$response = $client->getMessageFactory()->createResponse();\r\n\r\n// Send the request\r\n$client->send($request, $response);\r\n\r\nif($response->getStatus() === 200) {\r\n\r\n // Dump the requested page content\r\n echo $response->getContent();\r\n}\r\n```\r\n\r\nAnd if you would like to save a screen capture to local disk:\r\n\r\n```php\r\n<?php\r\n\r\nuse JonnyW\\PhantomJs\\Client;\r\n\r\n$client = Client::getInstance();\r\n\r\n/** \r\n * @see JonnyW\\PhantomJs\\Message\\Request \r\n **/\r\n$request = $client->getMessageFactory()->createCaptureRequest('http://google.com', 'GET');\r\n$request->setCaptureFile('/path/to/save/capture/file.jpg');\r\n\r\n/** \r\n * @see JonnyW\\PhantomJs\\Message\\Response \r\n **/\r\n$response = $client->getMessageFactory()->createResponse();\r\n\r\n// Send the request\r\n$client->send($request, $response);\r\n\r\n\r\n```\r\n\r\nFor more detailed examples see the [examples](http://jonnnnyw.github.io/php-phantomjs/examples.html) section, or to create your own custom scripts check out the [advanced](http://jonnnnyw.github.io/php-phantomjs/advanced.html) documentation.\r\n","google":"","note":"Don't delete this file! It's used internally to help with page regeneration."}