Software by Steven

Sometimes a square peg is a round hole

Gettin’ into Git and PHP Process Control

After my last foray with Mercurial, I’m now beginning to work with the distributed source control tool Git. And I like it. Like Hg, it seems it’s used for many projects including the Canvas 3D JS Library C3DL. Like SVN it provides source control, but unlike SVN it is great for its decentralized attitude and being able to run entirely locally if necessary. The learning curve is great too (almost linear) thanks to documentation like’s 20 Everyday Git Commands.

Of course Git isn’t enough to get any development done. I’ve been delving into PHP and how to issue commands to OS shells and receive output. Seems there are a lot of different options depending on what you want to do. The basic operations can be used via the system or exec functions, each of which return data back to the calling PHP script for further work. These two differ in two ways:

  • system() allows an array to be filled with all lines of the script output
  • exec() returns the entire output as a string rather than just the first line of output

In situations where the above isn’t enough or when dealing with binary output, the passthru function does the job nicely. This function seems to be the best of the lot: piping the script output directly back to the request stream rather than into PHP (which then goes to the stream) saves a ton of overhead if no additional formatting is required before displaying script output to the user.

As great as these functions are, the entire branch of PHP dealing with process control and program execution require PHP safe mode to be turned off. So it’s easy to use, just some configuration required.


2 responses to “Gettin’ into Git and PHP Process Control

  1. Pingback: World Wide News Flash

  2. Pingback: How PHP Process Control went wrong | Syntax Error

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: