Sunday, May 13, 2007

Hello PHP (and Ant)

I started the new job a week ago. The new gig requires me writing code in PHP. As a scripting language, PHP is very easy to use. It has great support for database connection, rich library and recently added AJAX features. But being a scripting language, it is also very easy to make a mess in your code base or development cycle. I noticed some developers check out source code and directly point their web server at their source code directory. I guess it make sense if the developer wants to see results quickly when he modifies source code. But I am always afraid of sharing the same files for development and deployment. If the application generates files at run time and the generated files might be accidentally checked into repository since they are in the development file directory. One mistake I have made myself in the past is to modify a code in the application directory and forgot to check it in. Also, in situation where it's impossible to run the entire application on a local host, it's just not possible to check out source code to a remote deployment box. I decided to take the responsibility of separating development environment and deployment environment. Since I love Java so much, I use Ant to filter and copy PHP scripts from source directory to staging directory, and use a shell script to move staged scripts to the correct deployment directory. This works out well.

No comments: