installation.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  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="/assets/resources/bootstrap/css/bootstrap.min.css" rel="stylesheet">
  15. <link href="/assets/resources/font-awesome/css/font-awesome.min.css" rel="stylesheet">
  16. <link href="/assets/resources/syntax/syntax.css" rel="stylesheet">
  17. <link href="/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="/feed.xml">
  26. </head>
  27. <body>
  28. <nav class="navbar navbar-default visible-xs" role="navigation">
  29. <!-- Brand and toggle get grouped for better mobile display -->
  30. <div class="navbar-header">
  31. <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
  32. <span class="sr-only">Toggle navigation</span>
  33. <span class="icon-bar"></span>
  34. <span class="icon-bar"></span>
  35. <span class="icon-bar"></span>
  36. </button>
  37. <!--
  38. <a type="button" class="navbar-toggle nav-link" href="mailto:contact@jonnyw.me">
  39. <i class="fa fa-envelope"></i>
  40. </a>
  41. -->
  42. <a class="navbar-brand" href="/">
  43. <img src="/assets/media/phantomjs-small.png" class="img-circle" />
  44. PHP PhantomJs
  45. </a>
  46. </div>
  47. <!-- Collect the nav links, forms, and other content for toggling -->
  48. <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
  49. <ul class="nav navbar-nav">
  50. <li class="active"><a href="/">Home</a></li>
  51. <li><a href="/installation.html">Installation</a></li>
  52. <li><a href="/usage.html">Usage</a></li>
  53. <li><a href="/advanced.html">Advanced</a></li>
  54. <li><a href="/debugging.html">Debugging</a></li>
  55. <li><a href="/troubleshooting.html">Troubleshooting</a></li>
  56. </ul>
  57. </div><!-- /.navbar-collapse -->
  58. </nav>
  59. <!-- nav-menu-dropdown -->
  60. <div class="btn-group hidden-xs" id="nav-menu">
  61. <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
  62. <i class="fa fa-bars"></i>
  63. </button>
  64. <ul class="dropdown-menu" role="menu">
  65. <li><a href="/"><i class="fa fa-home"></i>Home</a></li>
  66. <li><a href="/installation.html"><i class="fa fa-folder"></i>Installation</a></li>
  67. <li><a href="/usage.html"><i class="fa fa-folder"></i>Usage</a></li>
  68. <li><a href="/advanced.html"><i class="fa fa-folder"></i>Advanced</a></li>
  69. <li><a href="/debugging.html"><i class="fa fa-folder"></i>Debugging</a></li>
  70. <li><a href="/troubleshooting.html"><i class="fa fa-folder"></i>Troubleshooting</a></li>
  71. <li class="divider"></li>
  72. <li><a href="#"><i class="fa fa-arrow-up"></i>Top of Page</a></li>
  73. </ul>
  74. </div>
  75. <div class="col-sm-3 sidebar hidden-xs">
  76. <! -- sidebar.html -->
  77. <header class="sidebar-header" role="banner">
  78. <a href="/">
  79. <img src="/assets/media/phantomjs.png" class="img-circle" />
  80. </a>
  81. <h3 class="title">
  82. <a href="/">PHP PhantomJs</a>
  83. </h3>
  84. </header>
  85. <div id="bio" class="text-center">
  86. Run PhantomJS scripts through PHP
  87. </div>
  88. <div id="contact-list" class="text-center">
  89. <!--
  90. <ul class="list-unstyled list-inline">
  91. <li>
  92. <a class="btn btn-default btn-sm" href="mailto:contact@jonnyw.me">
  93. <i class="fa fa-envelope fa-lg"></i>
  94. </a>
  95. </li>
  96. </ul>
  97. <ul id="contact-list-secondary" class="list-unstyled list-inline">
  98. <li>
  99. <a class="btn btn-default btn-sm" href="/feed.xml">
  100. <i class="fa fa-rss fa-lg"></i>
  101. </a>
  102. </li>
  103. </ul>
  104. -->
  105. </div>
  106. <! -- sidebar.html end -->
  107. </div>
  108. <div class="col-sm-9 col-sm-offset-3">
  109. <div class="page-header">
  110. <h1>Installation </h1>
  111. </div>
  112. <article>
  113. <div class="col-sm-10">
  114. <div class="article_body">
  115. <h2 id="prerequisites">Prerequisites</h2>
  116. <p>PHP PhantomJS requires PHP <strong>5.3.0</strong> or greater to run.</p>
  117. <h2 id="installing-via-composer">Installing via Composer</h2>
  118. <p>Install <a href="https://getcomposer.org/">Composer</a> for your project:</p>
  119. <div class="highlight"><pre><code class="language-bash" data-lang="bash">curl -s http://getcomposer.org/installer <span class="p">|</span> php</code></pre></div>
  120. <p>Create a <code>composer.json</code> file in the root of your project:</p>
  121. <div class="highlight"><pre><code class="language-yaml" data-lang="yaml"><span class="p-Indicator">{</span>
  122. <span class="s">&quot;require&quot;</span><span class="p-Indicator">:</span> <span class="p-Indicator">{</span>
  123. <span class="s">&quot;jonnyw/php-phantomjs&quot;</span><span class="p-Indicator">:</span> <span class="s">&quot;3.*&quot;</span>
  124. <span class="p-Indicator">},</span>
  125. <span class="s">&quot;config&quot;</span><span class="p-Indicator">:</span> <span class="p-Indicator">{</span>
  126. <span class="s">&quot;bin-dir&quot;</span><span class="p-Indicator">:</span> <span class="s">&quot;bin&quot;</span>
  127. <span class="p-Indicator">},</span>
  128. <span class="s">&quot;scripts&quot;</span><span class="p-Indicator">:</span> <span class="p-Indicator">{</span>
  129. <span class="s">&quot;post-install-cmd&quot;</span><span class="p-Indicator">:</span> <span class="p-Indicator">[</span>
  130. <span class="s">&quot;PhantomInstaller\\Installer::installPhantomJS&quot;</span>
  131. <span class="p-Indicator">],</span>
  132. <span class="s">&quot;post-update-cmd&quot;</span><span class="p-Indicator">:</span> <span class="p-Indicator">[</span>
  133. <span class="s">&quot;PhantomInstaller\\Installer::installPhantomJS&quot;</span>
  134. <span class="p-Indicator">]</span>
  135. <span class="p-Indicator">}</span>
  136. <span class="p-Indicator">}</span></code></pre></div>
  137. <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>
  138. <p>Finally, install the composer depedencies for your project:</p>
  139. <div class="highlight"><pre><code class="language-bash" data-lang="bash">php composer.phar install</code></pre></div>
  140. <h2 id="custom-installation">Custom Installation</h2>
  141. <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>
  142. <div class="highlight"><pre><code class="language-php" data-lang="php"><span class="x">use JonnyW\PhantomJs\Client;</span>
  143. <span class="x"> $client = Client::getInstance();</span>
  144. <span class="x"> $client-&gt;setPhantomJs(&#39;/path/to/phantomjs&#39;);</span></code></pre></div>
  145. <p>If you would like composer to install the PhantomJS executable to a custom location when installing dependencies, set the bin dir location in your project’s <code>composer.json</code> file:</p>
  146. <div class="highlight"><pre><code class="language-yaml" data-lang="yaml"><span class="p-Indicator">{</span>
  147. <span class="s">&quot;config&quot;</span><span class="p-Indicator">:</span> <span class="p-Indicator">{</span>
  148. <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>
  149. <span class="p-Indicator">}</span>
  150. <span class="p-Indicator">}</span></code></pre></div>
  151. <p>You will need to make sure that this directory exists and is writable by Composer before running the composer install.</p>
  152. <p>Once you have updated your bin location run composer install to install PhantomJS:</p>
  153. <div class="highlight"><pre><code class="language-bash" data-lang="bash">php composer.phar install</code></pre></div>
  154. <p>This should install the correct PhantomJS executable for your system to the bin locaiton you defined in your <code>composer.json</code> file. As mentioned above, you will need to tell the client where to find your PhantomJS executable as it is not installed in the default location:</p>
  155. <div class="highlight"><pre><code class="language-php" data-lang="php"><span class="x">use JonnyW\PhantomJs\Client;</span>
  156. <span class="x"> $client = Client::getInstance();</span>
  157. <span class="x"> $client-&gt;setPhantomJs(&#39;/path/to/phantomjs&#39;);</span></code></pre></div>
  158. <h2 id="installing-from-tarball">Installing from tarball</h2>
  159. <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>
  160. <p>The PHP PhantomJS library currently requires the following depdencies:</p>
  161. <ul>
  162. <li><a href="https://github.com/symfony/Config">Symfony Config Component</a> ~2.5</li>
  163. <li><a href="https://github.com/symfony/Yaml">Symfony YAML Component</a> ~2.5</li>
  164. <li><a href="https://github.com/symfony/DependencyInjection">Symfony Dependency Injection Component</a> ~2.5</li>
  165. <li><a href="https://github.com/symfony/filesystem">Symfony Filesystem Component</a> ~2.5</li>
  166. <li><a href="https://github.com/fabpot/Twig">Twig templating Component</a> ~1.16</li>
  167. <li><a href="http://phantomjs.org/">PhantomJS</a> ~1.9</li>
  168. </ul>
  169. <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>
  170. </div>
  171. </div>
  172. <div class="clearfix"></div>
  173. <ul class="pager">
  174. <li class="previous"><a href="/usage.html" title="Usage">&larr; Usage</a></li>
  175. <li class="next"><a href="/introduction.html" title="Introduction">Introduction &rarr;</a></li>
  176. </ul>
  177. <hr>
  178. </div>
  179. <div class="col-sm-2 sidebar-2">
  180. </div>
  181. </article>
  182. <div class="clearfix"></div>
  183. <footer>
  184. <hr/>
  185. <p>
  186. &copy; 2014 PHP PhantomJs. Theme: Modified <a href="https://github.com/dbtek/dbyll">dbyll</a> by dbtek.
  187. </p>
  188. </footer>
  189. </div>
  190. <script type="text/javascript" src="/assets/resources/jquery/jquery.min.js"></script>
  191. <script type="text/javascript" src="/assets/resources/bootstrap/js/bootstrap.min.js"></script>
  192. <script type="text/javascript" src="/assets/js/app.js"></script>
  193. </body>
  194. </html>