index.html 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>Installation</title>
  6. <meta name="author" content="Jonny W">
  7. <!-- Enable responsive viewport -->
  8. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  9. <!-- Le HTML5 shim, for IE6-8 support of HTML elements -->
  10. <!--[if lt IE 9]>
  11. <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
  12. <![endif]-->
  13. <!-- Le styles -->
  14. <link href="http://jonnnnyw.github.io/php-phantomjs/assets/resources/bootstrap/css/bootstrap.min.css" rel="stylesheet">
  15. <link href="http://jonnnnyw.github.io/php-phantomjs/assets/resources/font-awesome/css/font-awesome.min.css" rel="stylesheet">
  16. <link href="http://jonnnnyw.github.io/php-phantomjs/assets/resources/syntax/syntax.css" rel="stylesheet">
  17. <link href="http://jonnnnyw.github.io/php-phantomjs/assets/css/style.css" rel="stylesheet">
  18. <!-- Le fav and touch icons -->
  19. <!-- Update these with your own images
  20. <link rel="shortcut icon" href="images/favicon.ico">
  21. <link rel="apple-touch-icon" href="images/apple-touch-icon.png">
  22. <link rel="apple-touch-icon" sizes="72x72" href="images/apple-touch-icon-72x72.png">
  23. <link rel="apple-touch-icon" sizes="114x114" href="images/apple-touch-icon-114x114.png">
  24. -->
  25. <link rel="alternate" type="application/rss+xml" title="" href="http://jonnnnyw.github.io/php-phantomjs/feed.xml">
  26. <script>
  27. (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  28. (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  29. m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  30. })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
  31. ga('create', 'UA-53289013-1', 'auto');
  32. ga('send', 'pageview');
  33. </script>
  34. </head>
  35. <body>
  36. <nav class="navbar navbar-default visible-xs" role="navigation" id="global-nav">
  37. <!-- Brand and toggle get grouped for better mobile display -->
  38. <div class="navbar-header">
  39. <button type="button" class="navbar-toggle" data-parent="#global-nav" data-toggle="collapse" data-target="#navbar-collapse-main">
  40. <span class="sr-only">Toggle navigation</span>
  41. <span class="icon-bar"></span>
  42. <span class="icon-bar"></span>
  43. <span class="icon-bar"></span>
  44. </button>
  45. <button type="button" class="navbar-toggle version-toggle" data-parent="#global-nav" data-toggle="collapse" data-target="#navbar-collapse-version">
  46. <span class="sr-only">Toggle navigation</span>
  47. <span class="fa fa-terminal"><b>3.0</b> version</</span>
  48. </button>
  49. <a class="navbar-brand" href="http://jonnnnyw.github.io/php-phantomjs/">
  50. <img src="http://jonnnnyw.github.io/php-phantomjs/assets/media/phantomjs-small.png" class="img-circle" />
  51. PHP PhantomJs
  52. </a>
  53. </div>
  54. <div class="panel">
  55. <!-- Collect the nav links, forms, and other content for toggling -->
  56. <div class="collapse navbar-collapse" id="navbar-collapse-version">
  57. <ul class="nav navbar-nav">
  58. <li><a href="http://jonnnnyw.github.io/php-phantomjs/4.0/" title="Version 4.0" class="active"><b>4.0</b> version</a></li>
  59. <li><a href="http://jonnnnyw.github.io/php-phantomjs/3.0/" title="Version 3.0"><b>3.0</b> version</a></li>
  60. </ul>
  61. </div><!-- /.navbar-collapse -->
  62. </div>
  63. <div class="panel">
  64. <!-- Collect the nav links, forms, and other content for toggling -->
  65. <div class="collapse navbar-collapse" id="navbar-collapse-main">
  66. <ul class="nav navbar-nav">
  67. <li><a href="http://jonnnnyw.github.io/php-phantomjs/3.0/">Introduction</a></li>
  68. <li><a href="http://jonnnnyw.github.io/php-phantomjs/3.0/2-installation/">Installation</a></li>
  69. <li><a href="http://jonnnnyw.github.io/php-phantomjs/3.0/3-usage/">Usage</a></li>
  70. <li><a href="http://jonnnnyw.github.io/php-phantomjs/3.0/4-advanced/">Advanced Usage</a></li>
  71. <li><a href="http://jonnnnyw.github.io/php-phantomjs/3.0/5-troubleshooting/">Troubleshooting</a></li>
  72. </ul>
  73. </div><!-- /.navbar-collapse -->
  74. </div>
  75. </nav>
  76. <!-- version-menu-dropdown -->
  77. <div class="btn-group hidden-xs" id="nav-version">
  78. <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
  79. <i class="fa fa-terminal"><b>3.0</b> version</i>
  80. </button>
  81. <ul class="dropdown-menu" role="menu">
  82. <li><a href="http://jonnnnyw.github.io/php-phantomjs/4.0/" title="4.0 version" class="active"><b>4.0</b> version</a></li>
  83. <li><a href="http://jonnnnyw.github.io/php-phantomjs/3.0/" title="3.0 version"><b>3.0</b> version</a></li>
  84. <li class="divider"></li>
  85. </ul>
  86. </div>
  87. <!-- nav-menu-dropdown -->
  88. <div class="btn-group hidden-xs" id="nav-menu">
  89. <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
  90. <i class="fa fa-bars"></i>
  91. </button>
  92. <ul class="dropdown-menu" role="menu">
  93. <li><a href="http://jonnnnyw.github.io/php-phantomjs/3.0/"><i class="fa fa-folder"></i>Introduction</a></li>
  94. <li><a href="http://jonnnnyw.github.io/php-phantomjs/3.0/2-installation/"><i class="fa fa-folder"></i>Installation</a></li>
  95. <li><a href="http://jonnnnyw.github.io/php-phantomjs/3.0/3-usage/"><i class="fa fa-folder"></i>Usage</a></li>
  96. <li><a href="http://jonnnnyw.github.io/php-phantomjs/3.0/4-advanced/"><i class="fa fa-folder"></i>Advanced Usage</a></li>
  97. <li><a href="http://jonnnnyw.github.io/php-phantomjs/3.0/5-troubleshooting/"><i class="fa fa-folder"></i>Troubleshooting</a></li>
  98. <li class="divider"></li>
  99. <li><a href="#"><i class="fa fa-arrow-up"></i>Top of Page</a></li>
  100. </ul>
  101. </div>
  102. <div class="col-sm-3 sidebar hidden-xs">
  103. <! -- sidebar.html -->
  104. <header class="sidebar-header" role="banner">
  105. <a href="http://jonnnnyw.github.io/php-phantomjs/">
  106. <img src="http://jonnnnyw.github.io/php-phantomjs/assets/media/phantomjs.png" class="img-circle" />
  107. </a>
  108. <h3 class="title">
  109. <a href="http://jonnnnyw.github.io/php-phantomjs/">PHP PhantomJs</a>
  110. </h3>
  111. </header>
  112. <div id="bio" class="text-center">
  113. Run PhantomJS scripts through PHP
  114. </div>
  115. <div id="contact-list" class="text-center">
  116. <ul class="list-unstyled list-inline">
  117. <li>
  118. <iframe src="http://ghbtns.com/github-btn.html?user=jonnnnyw&repo=php-phantomjs&type=watch&count=true"
  119. allowtransparency="true" frameborder="0" scrolling="0" width="85" height="20"></iframe>
  120. </li>
  121. <li>
  122. <iframe src="http://ghbtns.com/github-btn.html?user=jonnnnyw&repo=php-phantomjs&type=fork&count=true"
  123. allowtransparency="true" frameborder="0" scrolling="0" width="83" height="20"></iframe>
  124. </li>
  125. </ul>
  126. </div>
  127. <! -- sidebar.html end -->
  128. </div>
  129. <p id="version-notice">You are currently viewing version <span>3.0</span> documentation.</p>
  130. <div class="col-sm-9 col-sm-offset-3">
  131. <div class="page-header">
  132. <h1>Installation </h1>
  133. </div>
  134. <article>
  135. <div class="col-sm-10">
  136. <div class="article_body">
  137. <ul>
  138. <li><a href="#prerequisites">Prerequisites</a></li>
  139. <li><a href="#installing-via-composer">Installing via Composer</a></li>
  140. <li><a href="#custom-installation">Custom Installation</a></li>
  141. <li><a href="#installing-from-tarball">Installing from tarball</a></li>
  142. </ul>
  143. <hr />
  144. <h2 id="prerequisites">Prerequisites</h2>
  145. <p>PHP PhantomJS requires PHP <strong>5.3.0</strong> or greater to run.</p>
  146. <h2 id="installing-via-composer">Installing via Composer</h2>
  147. <p>Install <a href="https://getcomposer.org/">Composer</a> for your project:</p>
  148. <figure class="highlight"><pre><code class="language-bash" data-lang="bash"> <span class="c">#bash</span>
  149. <span class="nv">$ </span>curl -s http://getcomposer.org/installer <span class="p">|</span> php</code></pre></figure>
  150. <p>Create a <code>composer.json</code> file in the root of your project:</p>
  151. <figure class="highlight"><pre><code class="language-yaml" data-lang="yaml"> <span class="c1">#composer.json</span>
  152. <span class="p-Indicator">{</span>
  153. <span class="s">&quot;require&quot;</span><span class="p-Indicator">:</span> <span class="p-Indicator">{</span>
  154. <span class="s">&quot;jonnyw/php-phantomjs&quot;</span><span class="p-Indicator">:</span> <span class="s">&quot;3.*&quot;</span>
  155. <span class="p-Indicator">},</span>
  156. <span class="s">&quot;config&quot;</span><span class="p-Indicator">:</span> <span class="p-Indicator">{</span>
  157. <span class="s">&quot;bin-dir&quot;</span><span class="p-Indicator">:</span> <span class="s">&quot;bin&quot;</span>
  158. <span class="p-Indicator">},</span>
  159. <span class="s">&quot;scripts&quot;</span><span class="p-Indicator">:</span> <span class="p-Indicator">{</span>
  160. <span class="s">&quot;post-install-cmd&quot;</span><span class="p-Indicator">:</span> <span class="p-Indicator">[</span>
  161. <span class="s">&quot;PhantomInstaller\\Installer::installPhantomJS&quot;</span>
  162. <span class="p-Indicator">],</span>
  163. <span class="s">&quot;post-update-cmd&quot;</span><span class="p-Indicator">:</span> <span class="p-Indicator">[</span>
  164. <span class="s">&quot;PhantomInstaller\\Installer::installPhantomJS&quot;</span>
  165. <span class="p-Indicator">]</span>
  166. <span class="p-Indicator">}</span>
  167. <span class="p-Indicator">}</span></code></pre></figure>
  168. <p>It is important that you have the ‘scripts’ section shown above in your <code>composer.json</code> file as it will install the latest version of PhantomJS for your system to your project’s bin folder. It is recommended that you create a bin folder in the root of your project as this is where the PHP PhantomJS library will look for your PhantomJS executable. If you would prefer to use a PhantomJS executable in a custom location, see the <a href="#custom-installation">Custom Installation</a> section.</p>
  169. <p>Finally, install the composer depedencies for your project:</p>
  170. <figure class="highlight"><pre><code class="language-bash" data-lang="bash">
  171. <span class="c">#bash</span>
  172. <span class="nv">$ </span>php composer.phar install</code></pre></figure>
  173. <h2 id="custom-installation">Custom Installation</h2>
  174. <p>If you would prefer to use a custom install location for the PhantomJS executable, you simply need to tell the client where to find the executable file:</p>
  175. <figure class="highlight"><pre><code class="language-php" data-lang="php"><span class="x"> </span>
  176. <span class="x"> </span><span class="cp">&lt;?php</span>
  177. <span class="k">use</span> <span class="nx">JonnyW\PhantomJs\Client</span><span class="p">;</span>
  178. <span class="nv">$client</span> <span class="o">=</span> <span class="nx">Client</span><span class="o">::</span><span class="na">getInstance</span><span class="p">();</span>
  179. <span class="nv">$client</span><span class="o">-&gt;</span><span class="na">setPhantomJs</span><span class="p">(</span><span class="s1">&#39;/path/to/phantomjs&#39;</span><span class="p">);</span></code></pre></figure>
  180. <blockquote>
  181. <h4 id="important">Important</h4>
  182. <p>The PHP PhantomJS library also requires a <code>phantomloader</code> file that comes bundled with the library and is installed to the bin folder defined in your <code>composer.json</code> file. If you are setting a custom path to the PhantomJS executable, you need to make sure that the <code>phantomloader</code> file can be found in the bin folder it was installed to.</p>
  183. <p>See below if you wish to use a custom bin folder.</p>
  184. </blockquote>
  185. <p>If you would like composer to install all executable files to a custom bin location when installing dependencies, set the bin dir location in your project’s <code>composer.json</code> file:</p>
  186. <figure class="highlight"><pre><code class="language-yaml" data-lang="yaml"> <span class="c1">#composer.json</span>
  187. <span class="p-Indicator">{</span>
  188. <span class="s">&quot;config&quot;</span><span class="p-Indicator">:</span> <span class="p-Indicator">{</span>
  189. <span class="s">&quot;bin-dir&quot;</span><span class="p-Indicator">:</span> <span class="s">&quot;/path/to/your/projects/bin/dir&quot;</span>
  190. <span class="p-Indicator">}</span>
  191. <span class="p-Indicator">}</span></code></pre></figure>
  192. <p>You will need to make sure that this directory exists and is writable by Composer before running the composer install.</p>
  193. <p>Once you have updated your bin location run composer install to install PhantomJS:</p>
  194. <figure class="highlight"><pre><code class="language-bash" data-lang="bash">
  195. <span class="c">#bash</span>
  196. <span class="nv">$ </span>php composer.phar install</code></pre></figure>
  197. <p>This should install the correct PhantomJS executable for your system and the required <code>phantomloader</code> file to the bin locaiton you defined in your <code>composer.json</code> file. </p>
  198. <p>Now you need to tell the client where to find your bin folder:</p>
  199. <figure class="highlight"><pre><code class="language-php" data-lang="php"><span class="x"> </span>
  200. <span class="x"> </span><span class="cp">&lt;?php</span>
  201. <span class="k">use</span> <span class="nx">JonnyW\PhantomJs\Client</span><span class="p">;</span>
  202. <span class="nv">$client</span> <span class="o">=</span> <span class="nx">Client</span><span class="o">::</span><span class="na">getInstance</span><span class="p">();</span>
  203. <span class="nv">$client</span><span class="o">-&gt;</span><span class="na">setBinDir</span><span class="p">(</span><span class="s1">&#39;/path/to/bin/dir&#39;</span><span class="p">);</span></code></pre></figure>
  204. <h2 id="installing-from-tarball">Installing from tarball</h2>
  205. <p>The PHP PhantomJS library contains several depedencies in order to function so it is recommended that you install it via composer as this will handle your dependencies for you. If you do wish to install it from a <a href="https://github.com/jonnnnyw/php-phantomjs/tags">tarball release</a> then you will need to install the dependencies manually.</p>
  206. <p>The PHP PhantomJS library currently requires the following depdencies:</p>
  207. <ul>
  208. <li><a href="https://github.com/symfony/Config">Symfony Config Component</a> ~2.5</li>
  209. <li><a href="https://github.com/symfony/Yaml">Symfony YAML Component</a> ~2.5</li>
  210. <li><a href="https://github.com/symfony/DependencyInjection">Symfony Dependency Injection Component</a> ~2.5</li>
  211. <li><a href="https://github.com/symfony/filesystem">Symfony Filesystem Component</a> ~2.5</li>
  212. <li><a href="https://github.com/fabpot/Twig">Twig templating Component</a> ~1.16</li>
  213. <li><a href="http://phantomjs.org/">PhantomJS</a> ~1.9</li>
  214. </ul>
  215. <p>Make sure the components are in your include path and that the PhantomJS executable is installed to your projects bin folder as mentioned in the <a href="#custom-installation">Custom Installation</a> section.</p>
  216. </div>
  217. </div>
  218. <div class="clearfix"></div>
  219. <hr>
  220. <ul class="pager">
  221. <li class="previous"><a href="http://jonnnnyw.github.io/php-phantomjs/3.0/3-usage/" title="Usage">&larr; Usage</a></li>
  222. <li class="next"><a href="http://jonnnnyw.github.io/php-phantomjs/3.0/" title="Introduction">Introduction &rarr;</a></li>
  223. </ul>
  224. </article>
  225. <footer>
  226. <hr/>
  227. <p>
  228. &copy; 2016 PHP PhantomJs
  229. </p>
  230. </footer>
  231. </div>
  232. <script type="text/javascript" src="http://jonnnnyw.github.io/php-phantomjs/assets/resources/jquery/jquery.min.js"></script>
  233. <script type="text/javascript" src="http://jonnnnyw.github.io/php-phantomjs/assets/resources/bootstrap/js/bootstrap.min.js"></script>
  234. <script type="text/javascript" src="http://jonnnnyw.github.io/php-phantomjs/assets/js/app.js"></script>
  235. </body>
  236. </html>