When I do this, this is a multi-step process. Typically, an existing product exists to continue working. Rewriting from scratch is rarely an option, even if you end up doing it in the end.
- Start manual startup instructions and implement the autoloader where possible (takes many passes)
- Create a helper script to simulate magic quotes and register global variables. This means that you can disable it in PHP while maintaining existing code.
- Gradually remove excessive strip_slashes or add_slashes calls, if applicable. The helper script allows you to do this for each file.
- Make sure your variables have the correct scope.
- Separate your presentation code. Consider Smarty or an alternative template system.
- Move database calls to PDO and use parameter replacement for all
- Look at the code and think about lowering the front controller.
Then I look at the project and determine how I will change the logic itself. Often, if there are no functions at all, my first step is to wrap the general behavior in static methods. Get so much reuse without much effort, so I'm not organizing yet.
After reducing redundancy, I get an organization. At this point, I begin to plan my class models and refactor functions into pure methods. This is also the time for automated tests (phpunit). As soon as I'm confident, I add some controllers and integrate the templates, and then I finish ... with the exception of one or two passes.
For me, all this concerns determining where I am, where I want to be, and creating a plan that can be completed in a few small steps. Everyone has their own goals, so there is no magic plan other than your own.
pestilence669
source share