Notes on Tech, Social Media, and Entrepreneurship … Are you with the Band?
I’ve been doing developing in CakePHP, which is a pretty awesome rapid development framework, that tries (with 90% success) to give die-hard PHP developers a fast way to build up applications (similar to Ruby on Rails). I’ve only gotten my feet wet with it so far, but I can see it really going places.
One thing that always annoys me is developing code on my own machine, and transferring it onto a development/live server to see it in action. Previously I was doing all of my development in Dreamweaver, which has the ability to automatically upload files as you save each one. I got fed up with Dreamweaver, and switched to EasyEclipse (the main Eclipse bundled with useful plugins), and thought I would forever be stuck with Alt+Tab-ing to an FTP client, copying, pasting, waiting, cursing. Then I was looking through a CakePHP Bakery post, and found that Apache Ant can be used to FTP files. After seeing Francis’ script and doing some more stumbling, I hacked up my perfect build.xml file.
<project name="CakePHP Deployment" default="startPublish" basedir=".">
<buildnumber file="build.number"></buildnumber>
<property name="remoteDir" value="httpdocs"></property>
<property name="ftpSite"></property>
<property name="ftpUsername"></property>
<property name="ftpPassword"></property>
<target name="startPublish">
<antcall target="startFTP"></antcall>
</target>
<target name="startFTP">
<ftp server="${ftpSite}" userid="${ftpUsername}">
password="${ftpPassword}" timediffauto="true"
remotedir="${remoteDir}/app" action="send"
verbose="yes" passive="yes" depends="yes">
<fileset dir="app/" excludes="app/tmp;">
</fileset>
</ftp>
</target>
<target name="publishAll">
<ftp server="${ftpSite}" userid="${ftpUsername}">
password="${ftpPassword}" timediffauto="true"
remotedir="${remoteDir}" action="send"
verbose="yes" passive="yes">
<fileset dir=".">
</fileset>
</ftp>
</target>
</project>
From Eclipse, simply run the publishAll target one time - this copies all the CakePHP goodness onto your server. From then on, just run the startPublish target whenever you want to test something out. That will only copy the files in /app (this is the directory that all your custom code/configuration lives) that have changed up onto your server. It only takes me 5 minutes to run the first command, and ~1 minute to re-sync the files.
Note: You’ll need to add a couple libraries into ant in order for it to work. Brandon Harper’s post was very helpful.
…And thanks to Bennett for his CodeMarkup plugin.
My name is Zvi Band (pronounced zuh-vee), and I write this blog. You'll hear me talk about technology, social media, digital strategy, and entrepreneurship, all of which I am interested in.
I recently graduated (Go Terps!) and am working full time, however my heart lies in entrepreneurship. Watch me!
Everything I say is my own personal opinion, and should be treated as such. In this blog, what I say is not representative of my employer, clients, or anyone else other than myself.
Bennett
September 12th, 2007 at 3:20 am
You’re welcome.
Ant+FTP is a great idea for any website, not just Cake-based ones. I can’t imagine why I didn’t think of using Ant before, but I will use it in the future!
cyberpenguin
September 12th, 2007 at 12:58 pm
Hi Zvi,
(This is your blogger pal, Corey, of “See Corey Run”, http://seecoreyrun.blogspot.com.) Come on over & pick up your “Rockin’ Girl Blogger” award at my foodie blog, http://cookingwithcorey.blogspot.com.
Congrats!
-C
Zvi
September 12th, 2007 at 2:39 pm
Thanks Corey!
If only I was a rockin girl… sadly, I am merely a rockin boy.