4

I am a new programmer and I need your help. I'm pretty much new to Atom editor, but setup some nice packages like Atom Beautify. After using it in a html / php file I'm getting the error "Could not find 'php-cs-fixer' . The program may not be installed. The strange thing is, I did install the package php-cs-fixer but nothing happens.

My system is Windows.

Anyone got an idea how I can fix this?

shilovk
  • 11,718
  • 17
  • 75
  • 74

8 Answers8

10
  1. You must have installed "php" usually when installing the Wamp or Xampp servers are installed by default.     

  2. Download the file "php-cs-fixer.phar" https://github.com/FriendsOfPHP/PHP-CS-Fixer

  3. In the CMD execute this command: php where.exe

  4. You get a path, that path copy in: Open Atom Packages / Atom Beautify / Settings / Executables / PHP

  1. In the same folder where the php.exe is located copy the file "php-cs-fixer.phar"

  2. Redo the previous process with the CMD and the Atom in PHP-CS-Fixer "

dev.doc
  • 569
  • 3
  • 12
  • 18
  • 2
    These screenshots and explanation were really helpful. The explanation at https://github.com/FriendsOfPHP/PHP-CS-Fixer is completely ununderstandable to me. It says 'place "php-cs-fixer.phar" *anywhere* on your computer. ??? This is wrong, your explanation explains it should be in the folder where php.exe is. And the Atom-beautify settings are confusing too. One directly sees a heading 'PHP'. If you place the path at PHP-CS-Fixer path there, that's the wrong place.You should ignore that and go inside 'executables>PHP and place the pathes there. Thanks for giving the correct instructions! – Paul Gobée Jun 19 '19 at 21:51
  • @PaulGobée The note about adding `PHP-CS-FIXER` at `executables>PHP-CS-FIXER` is valid and highly recommended as the other option is now deprecated. However, I am not sure if it HAS to be at the same location of `php.exe` given that the documentation states otherwise. – Abdelrahman Shoman Apr 30 '21 at 14:57
3

I am not sure about in Windows, but on Mac and Linux, I do the following. You may be able to do this with Git Bash in Windows.

Install php-cs-fixer with Homebrew (via PHP-CS-Fixer Instructions)

brew install php-cs-fixer

Confirm php-cs-fixer was installed

which php-cs-fixer
ow3n
  • 5,974
  • 4
  • 53
  • 51
Ian
  • 1,746
  • 1
  • 15
  • 28
3

Just run this command in terminal, then it will work perfectly:

$ composer global require friendsofphp/php-cs-fixer

Everything will be fixed!

סטנלי גרונן
  • 2,917
  • 23
  • 46
  • 68
Asad
  • 31
  • 1
0

its because you need to install php cs fixer, the atom extension is trying to use it but its not currently installed on your system, install it here: https://github.com/FriendsOfPHP/PHP-CS-Fixer

Constantin Guidon
  • 1,892
  • 16
  • 21
  • 1
    I entered that link before and I download php-cs-fixer.phar file, but I didn't know how to follow the instructions, If you could clarify the procedure to me I will appreciate that, as I said before I am on Windows system, Thanks for your help – Muhammed Al-Awami Sep 03 '17 at 14:17
  • first of all, do you have `PHP` in your shell ? if so, you should install `composer` (https://getcomposer.org/) and with it install php-cs – Constantin Guidon Sep 03 '17 at 18:37
  • I have PHP because I am using XAMP – Muhammed Al-Awami Sep 04 '17 at 10:46
  • well that not's an answer to my question, so i reformulate it. When you open your terminal a type `php --version` do you have a version output ? Without it, it's a bit hard to develop any PHP application – Constantin Guidon Sep 04 '17 at 17:17
  • perfect so you have just to follow these steps install composer -> install php-cs-fixer , that's all! – Constantin Guidon Sep 07 '17 at 11:03
  • So far so good, but is there a specific location should I store the composer and the php-cs-fix – Muhammed Al-Awami Sep 07 '17 at 13:37
  • you have to install composer globaly in your case ( i think in windows its by default the case) for test the installation `composer -V`, if working then type `composer global require friendsofphp/php-cs-fixer` , after that it should be ok – Constantin Guidon Sep 08 '17 at 09:41
  • I already did that, but I need to set the path for PHP-CS-Fixer Config File & PHP-CS-Fixer Path in atom-beautify – Muhammed Al-Awami Sep 08 '17 at 13:00
  • i get these links, let me know if u have some trouble https://atom.io/packages/php-cs-fixer https://github.com/FriendsOfPHP/PHP-CS-Fixer/issues/145 – Constantin Guidon Sep 08 '17 at 13:57
  • I read that comments but didn't understand anything from there! – Muhammed Al-Awami Sep 09 '17 at 17:28
  • The github issue was to help to find the path of php-cs-fixer as you said earlier ( i'm not on windows so, i cant' really help you on this ) but i think its like `C:\xamp\bin\php\php7.1.7\php-cs-fixer.phar` – Constantin Guidon Sep 09 '17 at 22:58
0

I suggest you install manually the php-cs-fixer using the following steps:

  • You can use yum, apt, and other methods of installing a software or a .exe for windows
  • Get the path to the installed binary, for example for me i checked using whereis php-cs-fixer and I got /usr/bin/php-cs-fixer
  • Go to Packages > Atom Beautify > Settings > Executables > PHP-CS-FIXER then in the Binary/Script Path give the path of the php-cs-fixer above (/usr/bin/php-cs-fixer)
  • Enjoy beautify.
Victor Langat
  • 51
  • 1
  • 7
0

The issue for me was originally installing with composer. Composer does not put a .phar file into the /bin folder.

Download the .phar file (https://github.com/FriendsOfPHP/PHP-CS-Fixer#locally) and place it somewhere explicitly, then put that location in settings->executables->PHP-CS-Fixer path

Bryan
  • 3,449
  • 1
  • 19
  • 23
0

The manual way did work for me and this how I went about it;

  1. I download php-cs-fixer manually.
    $ wget https://cs.symfony.com/download/php-cs-fixer-v3.phar -O php-cs-fixer

or with curl

    $ curl -L https://cs.symfony.com/download/php-cs-fixer-v3.phar -o php-cs-fixer
  1. Then I fixed the rights and moved it to the right directory.
    $ sudo chmod a+x php-cs-fixer
    $ sudo mv php-cs-fixer /usr/local/bin/php-cs-fixer
  1. Finally, I ran php-cs-fixer and it worked.

full link

Phemelo Khetho
  • 231
  • 1
  • 4
  • 14
0
  1. make an empty folder somewhere. example: C:\Programs\php-cs-fixer
  2. run composer require friendsofphp/php-cs-fixer
  3. open atom and go to settings -> packages -> atom beautify -> settings -> executables -> php cs fixer input the path there: C:\Programs\php-cs-fixer\vendor\bin\php-cs-fixer.bat
  4. optionally: add C:\Programs\php-cs-fixer\vendor\bin to windows env path so you can use it from cli
Constantine
  • 650
  • 9
  • 15
Dota2Mods
  • 1
  • 2