Skip to content

Instantly share code, notes, and snippets.

@tairun
Last active October 10, 2017 11:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tairun/6a215cc732cf8b741bd2 to your computer and use it in GitHub Desktop.
Save tairun/6a215cc732cf8b741bd2 to your computer and use it in GitHub Desktop.
Get php beautification in atom-beautify working on windows in three easy steps.

How to get php-cs-fixer working on windows

There ist this package called atom-beautify for the atom text editor. It can, amongst many different languages, also beautify php. But if will not work out of the box on windows (see screenshot below). no php-cs-fixer.gif

Manual Install

  1. Install the php-cs-fixer.phar file and add it to your path.
    Go to this github page and download the php-cs-fixer.phar file. Next you need to add it to your path. Check cmd echo %PATH% to see which folders are being watched. I chose C:\Windows. Important: Now you need to remove the ending .phar or atom won't find the file.

  2. Install php and add it to your path.
    Official php windopws download-page. Grab the VC11 x86 Non Thread Safe package. See here why: https://stackoverflow.com/questions/1623914/what-is-thread-safe-or-non-thread-safe-in-php. Extract it somewhere, I chose C:\Windows\php. Add this location to path (userprofile) with command (in cmd window): setx PATH "%PATH%;C:\Windows\php" (for system path use setx /M ...).

  3. Restart Atom (to load new environment variables).

beautify editor php.gif

Automatic Install

I've created a script which will do this for you. Copy the following code into a powershell with elevated privileges and hit enter. For script execution directly in powershell you need to set Set-ExecutionPolicy Bypass first. If you wish to not touch your execution policy use cmd command from further below. Tested with powershell version:

> $PSVersionTable.PSVersion
  Major  Minor  Build  Revision
  -----  -----  -----  --------
  5      0      10240  16384

POWERSHELL: iex ((new-object net.webclient).DownloadString('https://gist.githubusercontent.com/tairun/19b0176b687bb320df90/raw/fd09327d62a4142a0463fa386372cd301df799e0/php-cs-fixer_install_script.ps1'))

CMD: @powershell -NoProfile -ExecutionPolicy unrestricted -Command "(iex ((new-object net.webclient).DownloadString('https://gist.githubusercontent.com/tairun/19b0176b687bb320df90/raw/fd09327d62a4142a0463fa386372cd301df799e0/php-cs-fixer_install_script.ps1'))) >$null 2>&1"

Here is the link to the script: https://gist.github.com/19b0176b687bb320df90

@jameibumblebee
Copy link

This script assumes one thing: that you have wget installed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment