Often times it happens in the life of php software development specialists that their managers assign them somebody else’s project nobody wants to take. Why? Because everything’s awfully messed up there and it seems you’ll never make it work.
But who is the big php development guru setting to work any software if not you? All you need is just some advice to get you up and running with it.
The most terrible PHP project a developer may inherit has certain characteristics that make it a real programming chaos. Usually they are the following:
- The original developers aren’t there anymore.
- The code supports no version control.
- Development and testing of the project were both done on live server by editing and renaming PHP files. Also there are lots of copies of the same files and no way to understand which of them are actually being used.
- Many files have other files included into them and these multiple inclusions are messing thing up very much.
- The project has been handed over across many developers, each with his own way of coding.
How to make it right
To start working on a project like this, first you need to get everything in order.
Here are 5 steps we recommend that you take to ensure this:
- Version control. It’s imperative that you get that project into version control disregarding how messy it is. Even if it works somehow and you break anything, you’ll need to go back to that working state, or just compare your changes with it to at least understand what went wrong. It’s necessary to do small and frequent check-ins while refactoring to have then less code when you have to roll back.
- Database. Ensure everything in it is relatively normalized, columns are named clearly, etc.
- PHP code. If that code is likely to take too much patchwork, it makes sense to fit it to some framework. I recommend that you choose Symfony or CakePHP as they have a way of separating concerns which makes it easier to decide where each piece of code should go. This isn’t a simple thing to do, but once it’s done, you are already halfway to a fairly constructed app. Besides, test facilities built in a good framework make it far easier to refactor your code, too. Before changing some piece of existing functionality, write a test covering it which will let you know if you broke anything afterwards.
- Cleaning up.With you database sorted, model code in models, and controller code in controllers, it’s time to take care of such presentation-level stuff as standardizing things on a single AJAX/JS library, and cleaning up CSS.
- Development environment. Finally, you should set up your local development environment. Use turnkey WAMP packages or install to a virtual machine like Linux Box or VirtualBox. You also need to get a separate integration testing environment which would mimics your live server. Ensure that he live server is used only for running live code.
Have you ever come across the same problems? What did you do?