Hudzilla.org - the homepage of Paul Hudson
Contents > Writing PHP > Group development Wish List | Report Bug | About Me ]

19.4.2     Version control

This is NOT the latest copy of this book; click here for the latest version.

When working with other programmers, especially if you are not in close proximity, you may find at one point that two people are working on the same PHP script at the same time. When they hit "Save", should the computer overwrite what the last programmer did, or should it bring up an error message and exit? Furthermore, what happens if a code problem crops up, and people want to revert to a previous version of a file?

These two problems are solved in the guise of version control, which is a centralised database of all files in your project. When a programmer wants to edit a script, they "check out" the script for editing. Other programmers who want to edit the script will see a notice that programmer A has checked it out, so they can choose whether to come back later or edit the same script anyway. When scripts are returned to the repository ("checked in", or "committed"), the version control system stores the new file version (as well the old versions) and allows others to read it. If two programmers commit a new script at the same time, the second programmer will receive a notice that someone has changed the file since they checked it out, and has the option of merging their changes and the other changes into a final file. This might sound risky, but in practice it works just fine most of the time.

Version control also adds a degree of change-tracking to your project. For example, if programmer B changes a file last edited by programmer A, that change will be recorded in the version control archive. If there is later a problem, the "culprit" can be tracked down and asked to fix it - or, perhaps better, the previous version of the code can be used instead. By storing each individual file version in its archive, you can also check differences between versions - you can compare v1.1 of a file against v2.1 of a file and see who made what code contributions and when they were released.

Using version control is pretty much mandatory for group programming - if you use Unix you probably have CVS (Concurrent Versions System) installed already. Windows programmers can also use CVS, but many use Microsoft's SourceSafe package, which integrates directly into Visual Studio. There are cross-platform version control systems available - a popular system is Seapine Surround SCM, which works smoothly on both Windows and Linux.





<< 19.4.1 How to develop code   19.5 Documenting your project >>
Table of Contents
Want to see this stuff in print? PHP in a Nutshell takes the core topics covered here, adds in thousands of edits from the editorial team and myself, and combines them to make an unbeatable reference for PHP programmers at all levels.



My latest book has hundreds more tips on how to use PHP, Apache, and MySQL, plus Perl, Python, shell scripts, performance tuning, and more!



Top-right shadow
 
Bottom-left shadow Bottom shadow

Comments from other readers
Be the first to add a comment to this chapter!



Add comment
Please note that by posting a comment here you are committing it to the public domain. This is important so that others can make use of your code themselves, and also so that I can incorporate helpful notes directly into the main text. Comments are limited to 2000 characters in length.

If you are reporting an error in the content, please tell me directly.

Your name/email address:
Your comment:
 
Now, in order to verify that you're a real person, please answer this simple question: what is one plus ten?
The answer is:
(please write in
numbers, eg 19)


Top-right shadow
 
Bottom-left shadow Bottom shadow