installation.rst 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. Installation
  2. ============
  3. - `Prerequisites <#prerequisites>`__
  4. - `Installing via Composer <#installing-via-composer>`__
  5. - `Custom Installation <#custom-installation>`__
  6. - `Installing from tarball <#installing-from-tarball>`__
  7. Prerequisites
  8. -------------
  9. PHP PhantomJS requires PHP **5.3.0** or greater to run.
  10. Installing via Composer
  11. -----------------------
  12. Install `Composer <https://getcomposer.org/>`__ for your project:
  13. .. code:: shell
  14. $ curl -s http://getcomposer.org/installer | php
  15. Create a ``composer.json`` file in the root of your project:
  16. .. code:: yaml
  17. {
  18. "require": {
  19. "jonnyw/php-phantomjs": "3.*"
  20. },
  21. "config": {
  22. "bin-dir": "bin"
  23. },
  24. "scripts": {
  25. "post-install-cmd": [
  26. "PhantomInstaller\\Installer::installPhantomJS"
  27. ],
  28. "post-update-cmd": [
  29. "PhantomInstaller\\Installer::installPhantomJS"
  30. ]
  31. }
  32. }
  33. It is important that you have the 'scripts' section shown above in your
  34. ``composer.json`` file as it will install the latest version of
  35. PhantomJS for your system to your project's bin folder. It is
  36. recommended that you create a bin folder in the root of your project as
  37. this is where the PHP PhantomJS library will look for your PhantomJS
  38. executable. If you would prefer to use a PhantomJS executable in a
  39. custom location, see the `Custom Installation <#custom-installation>`__
  40. section.
  41. Finally, install the composer depedencies for your project:
  42. .. code:: shell
  43. #bash
  44. $ php composer.phar install
  45. Custom Installation
  46. -------------------
  47. If you would prefer to use a custom install location for the PhantomJS
  48. executable, you simply need to tell the client where to find the
  49. executable file:
  50. .. code:: php
  51. use JonnyW\PhantomJs\Client;
  52. $client = Client::getInstance();
  53. $client->setPhantomJs('/path/to/phantomjs');
  54. If you would like composer to install the PhantomJS executable to a
  55. custom location when installing dependencies, set the bin dir location
  56. in your project's ``composer.json`` file:
  57. .. code:: yaml
  58. {
  59. "config": {
  60. "bin-dir": "/path/to/your/projects/bin/dir"
  61. }
  62. }
  63. You will need to make sure that this directory exists and is writable by
  64. Composer before running the composer install.
  65. Once you have updated your bin location run composer install to install
  66. PhantomJS:
  67. .. code:: shell
  68. #bash
  69. $ php composer.phar install
  70. This should install the correct PhantomJS executable for your system to
  71. the bin locaiton you defined in your ``composer.json`` file. As
  72. mentioned above, you will need to tell the client where to find your
  73. PhantomJS executable as it is not installed in the default location:
  74. .. code:: php
  75. use JonnyW\PhantomJs\Client;
  76. $client = Client::getInstance();
  77. $client->setPhantomJs('/path/to/phantomjs');
  78. Installing from tarball
  79. -----------------------
  80. The PHP PhantomJS library contains several depedencies in order to
  81. function so it is recommended that you install it via composer as this
  82. will handle your dependencies for you. If you do wish to install it from
  83. a `tarball release <https://github.com/jonnnnyw/php-phantomjs/tags>`__
  84. then you will need to install the dependencies manually.
  85. The PHP PhantomJS library currently requires the following depdencies:
  86. - `Symfony Config Component <https://github.com/symfony/Config>`__ ~2.5
  87. - `Symfony Dependency Injection
  88. Component <https://github.com/symfony/DependencyInjection>`__ ~2.5
  89. - `Symfony Filesystem
  90. Component <https://github.com/symfony/filesystem>`__ ~2.5
  91. - `Twig templating Component <https://github.com/fabpot/Twig>`__ ~1.16
  92. - `PhantomJS <http://phantomjs.org/>`__ ~1.9
  93. Make sure the components are in your include path and that the PhantomJS
  94. executable is installed to your projects bin folder as mentioned in the
  95. `Custom Installation <#custom-installation>`__ section.