views:

52

answers:

3

Hi folks, I had a web-based application outsourced (all PHP with jQuery and some other scripts and ajax). Now I am finished with the provider, and I'm slowly learning php and I'm wanting to begin refactoring this application so I can begin to more deeply understand it, and then begin adding more of the features I'm needing.

I have seen some of the refactoring videos online, and they are using teams and frameworks that are working in Java.

Are there any specific frameworks for refactoring in PHP and can you point me to any reading or information or beginner refactoring in PHP as a one-man operation?

Thank you!

A: 

The best advice I can give is write some kind of automated test to know that everything still works after refactoring.

Mike B
+5  A: 

Are there any specific frameworks for refactoring in PHP and can you point me to any reading or information or beginner refactoring in PHP as a one-man operation?

There is very little support for refactoring in the world of PHP tools, although M.M.H.Masud points out a number of links I didn't know yet - definitely worth checking out.

  • As Mike B already says, Unit Tests are very helpful for refactoring. If set up well, they can warn you if you break something during Refactoring.

    • Wikipedia article on Unit Testing

    • PHPUnit is kind of the industry standard in PHP based unit tests

    • SimpleTest is another PHP Unit testing tool, I haven't looked into it and it has not been maintained for two years but it still looks interesting

  • Be sure to use an IDE that supports syntax highlighting, jumping to function definitions and other helpful tools. Zend Studio can do this and NuSphere phpEdit, but they're both not free. Here's an SO question about free PHP IDEs and what they can do.

  • PhpXREF may be a helpful tool to "map" an unknown project

  • If you're refactoring a project, you'll want to document the code as you go along. If you do, make sure you use phpDocumentor syntax to possibly build an auto-generated API manual from it later.

  • Here is a question similar to yours with a few additional points and pointers.

Pekka