welovewordpress / SublimePhpTidy

Plugin for Sublime Text 2 to format PHP code to meet the WordPress Coding Standards using a modified version of phptidy
GNU General Public License v2.0
109 stars 30 forks source link

Cannot find php.exe Make sure it is available in your Path #4

Open rkmaier opened 12 years ago

rkmaier commented 12 years ago

What am I missing ? Where should i set the path to php. exe ?

welovewordpress commented 12 years ago

Your installation of PHP seems incomplete.

What happens when you type php.exe -v in your command line? It should display the version if PHP installed, but it will probably fail on your system.

Which PHP do you have installed? Do you have XAMMP or something similar installed which contains PHP? If you don't have any PHP installed, the plugin will not work.

rkmaier commented 12 years ago

Hi,

Thanks for your quick answer. I am using EasyPHP as Webserver on my local computer under WIN7 I get some strange dll missing file messages if i try to run the php.exe in my command line. But the webserver works just fine.

welovewordpress commented 12 years ago

@maersk, I'm afraid I won't be able to help you with that.

It's perfectly possible that your PHP install works fine when called from the Webserver, but fails when called via command line. I would still call that "a broken PHP installation".

I did some research and while I never used EasyPHP (I don't use Windows anymore and when I did, I was really happy with XAMPP which I can recommend since other users had no problems using XAMPP) I found some info regarding missing path (http://kevinjmorse.ca/articles/troubleshooting-pear-easyphp-wamp)

BUT: Since you get "some strange dll missing file messages", the problem is not that your php.exe cannot be found - but something else.

You should probably check the FAQ at http://www.easyphp.org/faq.php/ - it has some info on such DLL error messages. If this doesn't help, I recommend that you either ask people who know about EasyPHP (like in their forum) or you switch to XAMMP.

If you copied EasyPHP from another machine (instead of installing it fresh on your machine) it might help to do a fresh install.

Sorry, but this not something that I can fix by modifying the plugin...

rkmaier commented 12 years ago

Thanks for your Help. I will try going with XAMPP instead.

rkmaier commented 12 years ago

I installed xampp, but still have the same issue. Hower the installation seems fine. I ran the php.exe -v command with following result: PHP 5.3.8 (cli) (built: Aug 23 2011 11:50:20) Copyright (c) 1997-2011 The PHP Group Zend Engine v2.3.0, Copyright (c) 1998-2011 Zend Technologies

Must Xampp be installed on the C Drive?, because i have Xampp installed on my D drive.

welovewordpress commented 12 years ago

That's strange. No, it should be ok to install Xampp on D: - as long as the correct php.exe can be found by just running php.exe in the command line - which seems to be the case (now).

But my plugin does nothing else: It tries to run php.exe -v and if this fails, it will show the error message about php.exe not being found...

Could you please post the output from the Sublime Text Console - there might be something helpful in there.

rkmaier commented 12 years ago

Thats the message i get: PHPtidy cannot find php.exe. Make sure it is available in your PATH.

welovewordpress commented 12 years ago

Mayby I wasn't clear enough: To show the Sublime Text Console you need to select View -> Show Console from the menu. It will show a blank console window at the bottom of Sublime Text.

When I do this and run PhpTidy, I get the following output:

PhpTidy: invoked on file: /Users/krok/Documents/Sublime Projects/test.php
PhpTidy: Ok, this seems to be PHP
PhpTidy: buffer written to tmpfile: /tmp/phptidy-sublime-buffer.php
PhpTidy: calling script: /usr/bin/php "/Users/krok/Library/Application Support/Sublime Text 2/Packages/PhpTidy/wp-phptidy.php" replace "/tmp/phptidy-sublime-buffer.php"
PhpTidy: tmpfile was processed and removed

What do you get? (Lines should start with PhpTidy:)

Besides: It seems virtually impossible that you still get this error after installing XAMPP and confirming that php.exe -v works on the command line. It's probably not the installation itself but maybe the fact that you installed it just now.

So, did you try closing Sublime Text and opening it again (maybe the change in the systems PATH variable will take effect afterwards)? Or maybe you even need to restart windows for this to take effect? You shouldn't need to - but you never know with windows...

rkmaier commented 12 years ago

Here's the console output:

PhpTidy: invoked on file: None Traceback (most recent call last): File ".\sublimeplugin.py", line 362, in run File ".\php_tidy.py", line 9, in run TypeError: 'NoneType' object is unsubscriptable PhpTidy: invoked on file: C:\Users\maersk\AppData\Local\Temp\fz3temp-2\index.php PhpTidy: Ok, this seems to be PHP error: PhpTidy cannot find php.exe. Make sure it is available in your PATH.

I did a reboot after installing XAMPP.

welovewordpress commented 12 years ago

Ok, that's really strange.

I just added some debug info. Please upgrade the plugin using Package Control and run it again. This time, the console output should include a line containing "calling php.exe -v returned" followed by the error code.

Maybe this will help pin down the problem...

rkmaier commented 12 years ago

PhpTidy: invoked on file: C:\Users\maersk\AppData\Local\Temp\fz3temp-2\index.php PhpTidy: Ok, this seems to be PHP PhpTidy: calling php.exe -v returned: 1 error: PhpTidy cannot find php.exe. Make sure it is available in your PATH. (Error 1)

welovewordpress commented 12 years ago

Ok, return code 1 seems to stand for "Incorrect function" on windows (http://msdn.microsoft.com/en-us/library/ms681382(v=vs.85).aspx) - whatever that's supposed to mean.

But whatever the problem is, it is not "File not found" (error code 2) or "Path not found" (error code 3).

So, I just modified the plugin to skip this error code 1 and continue - instead of exiting at this step.

It will probably still not run through - but now, there should be something more helpful in the console log. At least we should be able to call the full command manually as the next step and see what this produces.

rkmaier commented 12 years ago

PhpTidy: invoked on file: D:\Project\PHPlive\phplive_.php PhpTidy: Ok, this seems to be PHP PhpTidy: calling php.exe -v returned: 1 PhpTidy: buffer written to tmpfile: C:\Users\maersk\AppData\Roaming\Sublime Text 2\Packages/PhpTidy/phptidy-sublime-buffer.php PhpTidy: calling script: php.exe "C:\Users\maersk\AppData\Roaming\Sublime Text 2\Packages/PhpTidy/wp-phptidy.php" replace "C:\Users\maersk\AppData\Roaming\Sublime Text 2\Packages/PhpTidy/phptidy-sublime-buffer.php" PhpTidy: script returned: 1 error: There was an error calling the script at C:\Users\maersk\AppData\Roaming\Sublime Text 2\Packages/PhpTidy/wp-phptidy.php. Return value: 1 PhpTidy: tmpfile was processed and removed

welovewordpress commented 12 years ago

Ok, great. So the plugin tries to run the following command

php.exe "C:\Users\maersk\AppData\Roaming\Sublime Text 2\Packages/PhpTidy/wp-phptidy.php" replace "C:\Users\maersk\AppData\Roaming\Sublime Text 2\Packages/PhpTidy/phptidy-sublime-buffer.php"

which returns the error code 1.

To get a more meaningful error message, run this exact command in your command line now.

You might want to ensure that the temporary file still exists at "C:\Users\maersk\AppData\Roaming\Sublime Text 2\Packages/PhpTidy/phptidy-sublime-buffer.php" or you could point it to another php file (which will be modified!).

Theoretically, if PHP has any other problems or warnings, it should output them as plain text when running from the command line. So, we should be getting there...

rkmaier commented 12 years ago

I ran the command from the command line. it didn't display any warning messages

welovewordpress commented 12 years ago

Well, I'm a little bit stumbling in the dark here - but as you say, the actual command runs without errors, I'll take its word for it and let it run... even with error code 1.

The whole plugin might be working for you now.

rkmaier commented 12 years ago

Well it didn't display any warning messages but the replace command doesn't get executed (the files content has not been replaced) and it displays the second files content

phpkunal commented 8 years ago

simple solution....For windows user go to the directory where you have installed xampp and now "search: php.exe" and you will get that file easily..now open that file by just right click on "php.exe" and open containg folder

Jawadkhatri commented 6 years ago

if you are using XAMPP make your Apache to be start then proceed the installation thanks