allenylzhou
allenylzhou

Reputation: 1461

sublime text 2 php tidy

I installed the phptidy plugin for Sublime Text 2 and tried to use it to clean up some ugly code like

$tdt="<td class=\"tit2\" ";
    $linka='<a href="products.php?action=history5&item=';

while ($row=mysql_fetch_array($r))
        {   extract($row);

But after running Php Tidy, a console flashed and it seems to have edited the entire file, but nothing actually changed. Does anyone know if the plugin below still works?

https://github.com/welovewordpress/SublimePhpTidy

Upvotes: 3

Views: 2135

Answers (2)

Ma Cheng
Ma Cheng

Reputation: 94

At first you must add the <?php ?> to beginning and end of your PHP file.

If you based-on Win, see the output of PHPTidy Processes on the 'Ctrl+`' Console.

There is a tip:

PhpTidy: calling php.exe -v returned: 0.

If it returns 1, maybe 'php.exe' wasn't found, add the path of your ‘php.exe’ to ENV.

Upvotes: 0

Brian Mego
Brian Mego

Reputation: 1469

I ran into the same problem. Console would open and close too fast to read what was going on.

Step 1: I opened up the Sublime Console (CTRL + ` on Windows)

Step 2: Reading the output gave me the hint. PhpTidy relies on php.exe being installed on your machine (duh)

This last step might seem obvious, but I was networked into another computer where the code lived and coding it over the wire. As such, when I ran phpTidy on my local machine, it failed due to the lack of php itself.

Upvotes: 5

Related Questions