-
Notifications
You must be signed in to change notification settings - Fork 453
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PHP beautification not working in Windows #288
Comments
Try updating to v0.26.4 and run the |
I can reopen this issue if it still exists and with additional information. v0.25.0 has since been released (as well as v0.26.0 and more) and has very drastic implementation changes that should clean issues like this up. |
Still not working ok. Atom Beautify - Debugging informationThe following debugging information was generated by Platform: win32 VersionsAtom Version: 0.196.0 Atom Beautify Version: 0.27.0 Original file to be beautifiedOriginal File Path: Original File Grammar: PHP Original File Contents: <html>
Hello
</html>
<?php
$listOfColors = array('green', 'yellow', 'red');
foreach ($listOfColors as $color) {
echo $color;
} ?> Beautification optionsEditor Options: {
"indent_size": 4,
"indent_char": " ",
"indent_with_tabs": false
} Config Options: {
"php": {
"cs_fixer_path": "C:\\php-5.5.3-Win32-VC11-x64\\php-cs-fixer.phar",
"fixers": "",
"level": ""
},
"cs": {
"configPath": ""
},
"c": {
"configPath": ""
},
"cpp": {
"configPath": ""
},
"css": {
"indent_size": 4,
"indent_char": " ",
"selector_separator_newline": false,
"newline_between_rules": false,
"preserve_newlines": false
},
"d": {
"configPath": ""
},
"html": {
"indent_inner_html": false,
"indent_size": 4,
"indent_char": " ",
"brace_style": "collapse",
"indent_scripts": "normal",
"wrap_line_length": 250,
"wrap_attributes": "auto",
"wrap_attributes_indent_size": 4,
"preserve_newlines": true,
"max_preserve_newlines": 10,
"unformatted": [
"a",
"sub",
"sup",
"b",
"i",
"u"
],
"end_with_newline": false
},
"java": {
"configPath": ""
},
"js": {
"indent_size": 4,
"indent_char": " ",
"indent_level": 0,
"indent_with_tabs": false,
"preserve_newlines": true,
"max_preserve_newlines": 10,
"space_in_paren": false,
"jslint_happy": false,
"space_after_anon_function": false,
"brace_style": "collapse",
"break_chained_methods": false,
"keep_array_indentation": false,
"keep_function_indentation": false,
"space_before_conditional": true,
"eval_code": false,
"unescape_strings": false,
"wrap_line_length": 0,
"end_with_newline": false
},
"objectivec": {
"configPath": ""
},
"pawn": {
"configPath": ""
},
"perl": {
"perltidy_profile": ""
},
"python": {
"max_line_length": 79,
"indent_size": 4,
"ignore": [
"E24"
]
},
"sql": {
"indent_size": 4,
"keywords": "upper",
"identifiers": "lower"
},
"vala": {
"configPath": ""
}
} Home Options: {} EditorConfig Options: {} Project Options: [
{}
] ResultsBeautified File Contents: Error: spawn php-cs-fixer ENOENT Logs:
|
I am also having this issue. I have NEVER been able to beautify anything with Atom.. |
When Atom is opened from a Terminal, it properly gets the environment variables in The error you are receiving indicates that PHP-CS-Fixer cannot be found, and therefore cannot be executed. Atom Beautify normally detects the proper environment variables for Operating Systems such as Linux (Ubuntu) and Mac; Windows is a very special case, as it's shell doesn't handle this well. I notice you have set Let's discuss some Windows workarounds. I do not use Windows for development so you'll have to test these and let me know if they work. Option 1) Run Atom from Terminal Option 2) Manually set
Let me know how this options work for you. These issues are related to Windows and environment variables in Node.js. These are not Atom Beautify specific, and more so related to Atom and Node.js. There are many other packages also having these issues. Atom Beautify attempts to resolve this issue automatically, however it works on other Operating Systems and not Windows. I hope that now you have an understanding of why this is happening and therefore can do some debugging on your own and contribute your knowledge and experiences back in this Issue for other Windows users. Thank you. |
Opening it in terminal has no effect for me. I am receiving the exact same error as OP. I agree, it probably indicates Atom can't find php-cs-fixer. I can confirm, than I can run it from cmd to fix a file, using "php-cs-fixer fix filename.php --level=psr2" and it works just fine. In windows, under my Environment Variables, I have composer in 2 spots. One for my user profile, and the other for the system. Variables for me: C:\Users\Wade\AppData\Roaming\Composer\vendor\bin and under the system variables: C:\ProgramData\ComposerSetup\bin. Since php-cs-fixer was not in the later, I copied it from one bin to another, just in case. This didn't help. In atom, I edited my init: I also tried the path to PHP, didn't help either. Between each attempt, I closed Atom and re-opened it. It seems like no combination of the paths helps. While I hope to get a MacBook in the near future, It should work in Windows. Even if we have to click "Browse" and select the folder php-cs-fixer is in, it should be looked at. |
I agree, however if we cannot even get it to work by manually changing the PATH then we cannot yet develop a nicer solution, such as browsing for the path and other options. Once we have a reproducible way to handle Windows then we can improve its usage. @guillempascual let me know if you have any luck. |
Hi @Glavin001, No luck. I've tried Option 1), no use, same fault. I'm really willing to help with this issue so me and other Windows users can make use of the beautifier. Thank you. That's the trace. Atom Beautify - Debugging informationThe following debugging information was generated by Platform: win32 VersionsAtom Version: 0.199.0 Atom Beautify Version: 0.27.2 Original file to be beautifiedOriginal File Path: Original File Grammar: PHP Original File Contents: <br/>
<?=$mensaje?>
<br/>
<br/>
<br/>
<table>
<tr>
<td style="font-weight:bold;" >
Centro
</td>
<td>
<?=(empty($direccion['centro']) ? "Tienda propia" : $direccion['centro']) ?>
</td>
</tr>
<tr>
<td style="font-weight:bold;vertical-align:top">
Dirección
</td>
<td>
<table>
<tr>
<td>
<?=$direccion['domicilio']?>
</td>
</tr>
<tr>
<td>
<?=$direccion['codigoPostal']?> <?=$direccion['poblacion']?>
</td>
</tr>
<tr>
<td>
<?=$direccion['provincia']?>
</td>
</tr>
</table>
</td>
</tr>
</table>
<br/>
<hr/>
<table>
<tr>
<td style="font-weight:bold;vertical-align:top">
Tienda
</td>
<td>
<?=$pedido['nombreTienda']?><br/><?=$pedido['nombreDelegacion']?>
<tr>
<td style="font-weight:bold;vertical-align:top">
Contacto
</td>
<td>
<table>
<tr>
<td>
<?=$pedido['personaContacto']?>
</td>
</tr>
<tr>
<td>
<?=$pedido['movilCliente']?>
</td>
</tr>
<tr>
<td>
<a href="<?=$pedido['emailCliente']?>" target="_blank"><?=$pedido['emailCliente']?></a>
</td>
</tr>
</table>
</td>
</tr>
</table>
<br/>
<table>
<thead>
<tr>
<th style="text-align: left">Modelo</th>
<th style="text-align: left">N.Serie</th>
<th style="text-align: left">Product Number</th>
<th style="text-align: left">Descripción</th>
<th style="text-align: left">Cantidad</th>
</tr>
</thead>
<tbody>
<?php foreach ($pedido['lineas_pedido'] as $linea_pedido): ?>
<tr>
<td style="width:100px"><?=$linea_pedido['fm11500DescArtic']?></td>
<td style="width:100px"><?=$linea_pedido['fg20700NumSerie']?></td>
<td style="width:100px"><?=$linea_pedido['ProductNumber']?></td>
<td style="width:100px"><?=$linea_pedido['MarkerColor']?></td>
<td style="width:100px">1 ud.</td>
</tr>
<?php endforeach ?>
</tbody>
</table> Beautification optionsEditor Options: {
"_default": {
"indent_size": 4,
"indent_char": " ",
"indent_with_tabs": false
}
} Config Options: {
"php": {
"cs_fixer_path": "C:\\php-5.5.3-Win32-VC11-x64\\php-cs-fixer.phar",
"fixers": "",
"level": ""
},
"cs": {
"configPath": ""
},
"c": {
"configPath": ""
},
"cpp": {
"configPath": ""
},
"css": {
"indent_size": 4,
"indent_char": " ",
"selector_separator_newline": false,
"newline_between_rules": false,
"preserve_newlines": false
},
"d": {
"configPath": ""
},
"html": {
"indent_inner_html": false,
"indent_size": 4,
"indent_char": " ",
"brace_style": "collapse",
"indent_scripts": "normal",
"wrap_line_length": 250,
"wrap_attributes": "auto",
"wrap_attributes_indent_size": 4,
"preserve_newlines": true,
"max_preserve_newlines": 10,
"unformatted": [
"a",
"sub",
"sup",
"b",
"i",
"u"
],
"end_with_newline": false
},
"java": {
"configPath": ""
},
"js": {
"indent_size": 4,
"indent_char": " ",
"indent_level": 0,
"indent_with_tabs": false,
"preserve_newlines": true,
"max_preserve_newlines": 10,
"space_in_paren": false,
"jslint_happy": false,
"space_after_anon_function": false,
"brace_style": "collapse",
"break_chained_methods": false,
"keep_array_indentation": false,
"keep_function_indentation": false,
"space_before_conditional": true,
"eval_code": false,
"unescape_strings": false,
"wrap_line_length": 0,
"end_with_newline": false
},
"objectivec": {
"configPath": ""
},
"pawn": {
"configPath": ""
},
"perl": {
"perltidy_profile": ""
},
"python": {
"max_line_length": 79,
"indent_size": 4,
"ignore": [
"E24"
]
},
"sql": {
"indent_size": 4,
"keywords": "upper",
"identifiers": "lower"
},
"vala": {
"configPath": ""
}
} Home Options: {
"_default": {}
} EditorConfig Options: {
"isFulfilled": false,
"isRejected": false
} Project Options: [
{
"_default": {}
},
{
"_default": {}
},
{
"_default": {}
},
{
"_default": {}
},
{
"_default": {}
}
] ResultsBeautified File Contents: Error: spawn php-cs-fixer ENOENT Logs:
|
Published fix to v0.27.3 Please let me know if that works. |
I don't know that this should be closed before anyone can give feedback. This still is not working for me, and it is not giving any error now. It just pops up a window for half a second, and does nothing. So I ran the Beautify debug to look at the contents:
NOTE: I can run I have been programming for a long time, but I am fairly new to Composer, Git, and all that. So I could have missed something along the way. I don't think that anyone who used Composer to install php-cs-fixer would have the files anywhere else either, unless they manually moved them? So I don't see how this would work out of the box installing via Composer. |
I close issues via commit messages, so that is automatic. It is trivial to reopen an issue, if it does not work.
This is strange, that should not work on Windows. From my experience (see #269 ), Windows requires running For Windows, I have added back the option The applicable code can be found here: atom-beautify/src/beautifiers/php-cs-fixer.coffee Lines 18 to 30 in 6fdeec5
I think at this point, I would recommend changing the arguments passed to @run yourself and do some debugging for your setup.
There may need to be multiple ways to handle different configurations on Windows, and since I do not even have a Windows computer to replicate any of them, I recommend that each of you attempt to simply change those values until it works for you and then let me know. Thank you. |
@Glavin001 I later thought it was closed automatically. After a few more tests, and after your update, I have gotten it working. It seems impossible to get it working without using the For the record, I am on Windows 8.1 64b. I hope to get a MacBook soon, but for now it isn't possible. Normal programming wasn't a problem in the past, but using Composer, Git, and various other new technologies have made Mac's more and more desirable. It seems they are all made for Mac, and Windows second. On top of Mac's having a similar structure to Linux servers, as they are Unix based themselves. How I got it workingI first downloaded the phar file from PHP-CS-Fixer on GitHub and placed it in my Composer's bin folder, right along with the files Composer installed (ie: php-cs-fixer executable). In Atom, under Settings > Packages > Atom Beautify Settings: I scrolled down to where you can set the path for php-cs-fixer, and set it to: I also changed the psr level to psr2 while I was there. Closed Atom and re-opened it. Loaded a php file and tested it. Boom, it's been Beautified :) Maybe my problem the whole time was just not using the Unfortunately, I still can not run |
@guillempascual , to answer your questions:
There were major changes to the internal workings of Atom Beautify. See #282 for details, however even some of what is written there is outdated. Basically, I wanted to get rid of the manually setting of the paths for CLI beautifiers executables. With help from @ioquatix with https://github.com/ioquatix/script-runner I was able to make it work for Mac and Linux. However, Windows support is not yet there, at least for automatic detection of environment variables. I decided that we could just have the Windows users manually change their Init script for Atom (what you both did above) such that Atom Beautify, and all other applicable packages, would have a fixed
I accidently removed the atom-beautify/src/beautifiers/php-cs-fixer.coffee Lines 18 to 30 in 6fdeec5
I have also added back the option for setting the PHP CS Fixer Path manually, for Windows. Give this a try and let me know if that works for you.
If the PHP CS Fixer code is located at I'll try and help best I can, but I think if these latest changes do not work, I recommend that each of you do your own testing and changing of the contents of the php-cs-fixer.coffee file. Since I cannot debug on Windows, until each of you are able to get it working, I cannot develop a final solution (if the latest does not work). Thanks! |
Hey @Glavin001!! As of 0.27.4 now it works like a charm!!! Excellent job!! Thank you!!! As to where the source were located, my mistake, I meant src/beautifiers/php-cs-fixer.coffee, I really had the latest update. Thank you. |
Excellent! Thank you both for reporting back. Now that we have a working version, I can focus on making the experience easier for getting this configured by the user, such as:
For the future, I think I would like to look into the ability to auto-detect installations and locations of the
Thanks for the teamwork! Hopefully this will help other PHP and Atom Beautify users get started and the experience can be improved for the future. |
@Glavin001 yes I first tried Composer but something went wrong and Beautifier wasn't able to locate it so I switched to manual installation. C:\Users\Guillem> where php-cs-fixer.phar => returns "C:\php-5.5.3-Win32-VC11-x64\php-cs-fixer.phar". Thank you. |
Using |
I fixed it setting PHP-CS-FIXER PATH: |
I really want to focus on improving the installation experience for users. I have created a new Issue, #1687, to target this problem. Please provide your feedback! Thanks in advance. |
When beautifying from inside Atom nothing happens: nor fixing nor any error message.
If I run php C:\php-5.5.3-Win32-VC11-x64\php-cs-fixer.phar fix example.php it works perfectly.
I have uninstalled and installed back Atom-beautify.
This is the debug trace:
Atom Beautify - Debugging information
The following debugging information was generated by
Atom Beautify
onFri Apr 24 2015 12:16:27 GMT+0200 (Hora de verano romance)
.Platform: win32
Versions
Atom Version: 0.192.0
Atom Beautify Version: 0.24.1
Original file to be beautified
Original File Path:
C:\tools\example.php
Original File Grammar: PHP
Original File Contents:
Beautification options
Editor Options:
Options from Atom Editor settings
Config Options:
Options from Atom Beautify package settings
Home Options:
Options from
C:\home\.jsbeautifyrc
EditorConfig Options:
Options from EditorConfig file
Project Options:
Options from
.jsbeautifyrc
files starting from directoryC:\tools
and going up to rootLogs
Error logs: Not yet supported
The text was updated successfully, but these errors were encountered: