0

I would like to write a web interface that shows the differences between two very large files. I normally use winmerge, but that means I need to log into a server copy the files and then compare them. One too many steps for my liking. I want to write a web interface that basically does the same thing. Does anyone know of a good reliable php library out there which does something like this? Keep in mind this files are 20k lines long so it needs to be reliable, not need for super fast.

Renzosilv
  • 1
  • 2
  • 5
    and what have you tried? – Bhavik Shah Feb 20 '13 at 04:05
  • I'm currently actually doing what was suggested by Amandan. Running a system command and displaying the results with some formatting. Users don't seem to like the formatting though and I figured there must be a library out there which does it for me. The side by side comparison with the lines shifted to always match is the most requested feature and I didn't want to 're-invent the wheel. – Renzosilv Feb 21 '13 at 02:13

2 Answers2

2

Use system command diff, then parse the results. The format is regular and easy to figure out.

Amadan
  • 191,408
  • 23
  • 240
  • 301
0

To add to Amadan's idea:

Create an HTML form with two file input fields and use the following:

echo exec('diff ' . $_FILES['file1']['tmp_name'] . ' ' . $_FILES['file2']['tmp_name']);
Nick Pickering
  • 3,095
  • 3
  • 29
  • 50
  • `exec` only returns the last line, so this would not work very well. You either want the backticks, the `system` command (without `echo` in that case), or utilise the second parameter to `exec`. Also, I would hate plain `diff` output on a webpage if I was used to WinMerge - thus "parse the results". – Amadan Feb 20 '13 at 04:33
  • I was just digging a little deeper, I agree with all of your points. If he hadn't known how to execute a system command from within PHP, this would have given him what he needed. Obviously the output would need to be parsed and prettied up for a webpage. – Nick Pickering Feb 20 '13 at 04:41