About Adam

Adam Stout works in the technology field and is currently located in San Diego, CA.




Recent Entries


Deploying PHP with PHING

Posted: Jul 06, 2010
A couple of months ago I came across PHING, a deployment system for PHP.  It seems pretty straight forward to use and really tuned for PHP.  It has tons of extensions to use all the tools a PHP developer would want.  I finally have something that will run on Windows or Linux and will mange deployments on my local box, a prototype server, or my productions servers and all I have to do is put together a little XML config file.

I alike that it is so easily customizable as well.  For instance, my production server runs PHP in cgi mode so I can't change PHP settings in the .htaccess fiel so I have to have a php.ini file in every directory that has PHP to change these settings (on a side note, I'm looking forword to getting php5.3 installed which introduces the .user.ini setting which works like a .htaccess just for PHP).  I really didn't want to maintain serveral copies of the same php.ini file so I wrote a little adhoc-task which expands PHING to copy a single file to every directory in the tree.  A couple of lines of PHP in my PHING build.xml and I'm up and running.

    <adhoc-task name="copyrecurse">
    class copyRecurse extends Task 
        private $file;
        private $todir;
        private $file_name;
function setFile($file) { 
            $this->file $file
function setToDir($todir) {
            $this->todir $todir
private function getDirectoryTree($BASE_DIR,$LEVEL=1){
            $THIS_DIR array_diffscandir($BASE_DIR), array_merge(array( ".""..",".svn")) );
            foreach( $THIS_DIR as $DIR ) {
                    copy($this->file$BASE_DIR."/".$DIR "/" $this->file_name);
            return true;
        <br>        function main() { 
            $this->file_name basename($this->file);
            $this->getDirectoryTree($BASE_DIR $this->todir);
    <copyrecurse file="${workingDir}php.ini" todir="${workingDir}/>

I'm looking forward to using PHING in the future and integrating some of the tools it gives me access to.  Hopefully more of us will start using it to help ensure it is maintained going forward.


Please log on to add your comments.