Wednesday, February 24, 2010

GIT as version control system

I have been using GIT as version control system for a while. What impressed me most is GIT's branch management and merging.

You have a clean code base called master. Now you need to implement a new feature to your application. What you need to do is to create a new branch for this task, just like this: git branch new_feature_1. And then you can checkout this branch: git checkout new_feature_1. Now you have switch from master to new_feature_1, and you can start work on your feature on this branch.

If one day, while you are still in the middle of the new_feature_1, your manager comes and tells you 'hey, we have an urgent feature that must be done asap, and it has the highest priority'. You can simple save all your current work: git commit -a. This will commit all your work to the new_feature_1 branch. Then you can checkout master, the clean code base and create a new branch: urgent_feature.

Most people using CVS/SVN have painful experience with branch merging. GIT makes merging an incredibly simple and easy task. After you finish your work, you can simply merge it from master: git merge urgent_feature. Now, you can checkout new_feature_1 branch and continue your work. If you want to use some new functionalites in urgent_feature, you can simply merge the master branch or urgent_feature branch.

Monday, February 15, 2010

exec() vs system()

Besides all the descriptions from PHP manual, let us do a small test. Create a file called test.php:
echo 'hello';

Create another file called runexec.php:
exec('php test.php');

Create a runsystem.php:
system('php test.php');

All three files are located in the same directory. I found runexec.php cannot call test.php properly. I must use full path in the exec command. However, runsystem.php can work very well.