installation.rst 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. ============
  2. Installation
  3. ============
  4. Requirements
  5. ------------
  6. PHP needs to be a minimum version of PHP 7.4.
  7. Installation
  8. ------------
  9. Locally
  10. ~~~~~~~
  11. Download the `php-cs-fixer.phar`_ file and store it somewhere on your computer.
  12. Globally (manual)
  13. ~~~~~~~~~~~~~~~~~
  14. You can run these commands to easily access latest ``php-cs-fixer`` from anywhere on
  15. your system:
  16. .. code-block:: console
  17. wget https://cs.symfony.com/download/php-cs-fixer-v3.phar -O php-cs-fixer
  18. or with specified version:
  19. .. code-block:: console
  20. wget https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/releases/download/v3.13.0/php-cs-fixer.phar -O php-cs-fixer
  21. or with curl:
  22. .. code-block:: console
  23. curl -L https://cs.symfony.com/download/php-cs-fixer-v3.phar -o php-cs-fixer
  24. then:
  25. .. code-block:: console
  26. sudo chmod a+x php-cs-fixer
  27. sudo mv php-cs-fixer /usr/local/bin/php-cs-fixer
  28. Then, just run ``php-cs-fixer``.
  29. Globally (Composer)
  30. ~~~~~~~~~~~~~~~~~~~
  31. To install PHP CS Fixer, `install Composer <https://getcomposer.org/download/>`_ and issue the following command:
  32. .. code-block:: console
  33. composer global require friendsofphp/php-cs-fixer
  34. Then make sure you have the global Composer binaries directory in your ``PATH``. This directory is platform-dependent, see `Composer documentation <https://getcomposer.org/doc/03-cli.md#composer-home>`_ for details. Example for some Unix systems:
  35. .. code-block:: console
  36. export PATH="$PATH:$HOME/.composer/vendor/bin"
  37. Globally (homebrew)
  38. ~~~~~~~~~~~~~~~~~~~
  39. .. code-block:: console
  40. brew install php-cs-fixer
  41. Locally (PHIVE)
  42. ~~~~~~~~~~~~~~~
  43. Install `PHIVE <https://phar.io>`_ and issue the following command:
  44. .. code-block:: console
  45. phive install php-cs-fixer # use `--global` for global install
  46. Gitlab-CI (Docker)
  47. ~~~~~~~~~~~~~~~~~~
  48. To integrate php-cs-fixer as check into Gitlab-CI, you can use a configuration like this:
  49. .. code-block:: yaml
  50. php-cs-fixer:
  51. image: ghcr.io/php-cs-fixer/php-cs-fixer:${FIXER_VERSION:-3-php8.3}
  52. script:
  53. php-cs-fixer check --diff --format=txt src
  54. Update
  55. ------
  56. Locally
  57. ~~~~~~~
  58. The ``self-update`` command tries to update ``php-cs-fixer`` itself:
  59. .. code-block:: console
  60. php php-cs-fixer.phar self-update
  61. Globally (manual)
  62. ~~~~~~~~~~~~~~~~~
  63. You can update ``php-cs-fixer`` through this command:
  64. .. code-block:: console
  65. sudo php-cs-fixer self-update
  66. Globally (Composer)
  67. ~~~~~~~~~~~~~~~~~~~
  68. You can update ``php-cs-fixer`` through this command:
  69. .. code-block:: console
  70. ./composer.phar global update friendsofphp/php-cs-fixer
  71. Globally (homebrew)
  72. ~~~~~~~~~~~~~~~~~~~
  73. You can update ``php-cs-fixer`` through this command:
  74. .. code-block:: console
  75. brew upgrade php-cs-fixer
  76. Locally (PHIVE)
  77. ~~~~~~~~~~~~~~~
  78. .. code-block:: console
  79. phive update php-cs-fixer
  80. .. _php-cs-fixer.phar: https://cs.symfony.com/download/php-cs-fixer-v3.phar