16
05/07
3:19 am
Automate your web development! No more repetitive tasks!
Many people think web developers are lazy, but that’s not always true. One thing I can confirm is that we don’t like repeating ourselves. Unfortunately we sometimes do it without even knowing.
This blog post is going to briefly explain how I’ve managed to automate almost every part of my PHP web development.
Below are some important tasks you should also automate:
1. Mac/PC setup for web development
Make sure you’re never manually clicking, loading or running any apps EVERYTIME you open your computer. Add them to a script or batch file, and load it in your Startup Folder or Login Items. Here’s what I have: Text Editor, Browser, Terminal window (x2), Mail App, News Reader, Music Player, Apache, Mysql (server). For me, it takes these to get right into “web development mode“.
2. Creating an application (database,framework,repository)
Most web applications use a database, a framework, and a repository for source control. If you’re not using those 3 then this post isn’t for you, or you’re just not in the loop ;) Let’s assume every web application you develop uses this formula. You need to create a script which automates database creation, automatically loads your favorite framework, creates a repository for your application and imports it.
3. Version control through text editor
What’s fun about version/source control when you’re constantly switching to a Terminal window to update, add and delete files? Automate it! If you use TextMate then you’ll love the neat Subversion bundle. If you use Smultron, you’ll need to define a set of custom commands. Either way, this will save you a ton of time when writing code.
4. Updating applications (WordPress, CodeIgniter, etc)
You just created a custom wordpress theme, tweaked the config file and got everything working properly. All of a sudden, WordPress announces a new version of their application. Important security fixes! Uh oh! Have fun updating! Don’t skip a step, or your blog won’t work! A total nightmare, right? WRONG! Just automate it! How? It’s called vendor branches. Ask Google. Once you get it, you’ll be on your way to updating WordPress in 1 simple step.
5. Website deployment (no more ftp!)
Everything works locally, so now it’s time to deploy! How do you deploy your new application without any downtime? With FTP, you can upload the application under a different name, rename or delete the old one, then rename the new one. You can try to overwrite the application and hope it works. Or you can automate it. Time to bring out the big guns. Capistrano! It is made for that and yes it works with PHP applications. Once you have it all setup, you’ll be able to deploy your new application and updated versions with 1 simple command.
I know this seems like a lot of work, but once it’s done, you won’t have to worry about repetitive tasks and everything will just work.
Good luck!
Barry Hess
May 16, 2007
10:12 pm
Very nice post, Alex. Kind of like my recent post on making note-taking a bit more brainless (although your post is a lot better :).
In any case, I definitely need to look at my login items. I suspect it will be a little annoying to login for personal use and find all these login items starting up. That would rarely get in the way, though, so I guess “who cares.”
What terminal app do you use on your Mac? I’m using iTerm, though I’m not sure whether it’s the best option.
(This also makes me think I should start working with WordPress more intimately rather than going with whatever my webhost offers for installation. I’m just getting familiar with Vendor Branches and I have a process setup for merging in Rails updates. I’ve just never integrated Wordpress, or any blogging tool, fully with an application. So little time…)
richard rabins
May 17, 2007
7:54 am
Alex — I read your post with great interest because it adresses the benefits of work “smart” as opposed to working “hard”.
As an aside I am associated with a company that makes a tool for creating secure database web applications with full reporting very rapidly.
The tool is Alpha Five and Version 8 was just introduced
http://www.alphasoftware.com/press/releases/
If any ISV or IT person reading your blog would like to get a full copy (not a trial) for free (normal price $349) they can email me and reference your blog.
Best Regards
Richard Rabins
richard rabins
May 17, 2007
7:56 am
btw – it probably would help to leave my email richard@alphasoftware.com
Alex
May 17, 2007
10:36 am
@richard: Thanks for your generosity. I use a Mac for development so I have no use for Alpha Five, although I’m sure it can be of great use for other developers out there.
@Barry: I just use Terminal which ships with OS X. It can be found in Applications->Utilities directory.
I’ve got some code examples for people to customize and automate their own tasks. Unfortunately they were all hacked together real quickly and are not generic enough. I’ll let you know when they’re ready.
Barry Hess
May 17, 2007
9:38 pm
I’d love to see some automation code samples. After spending som time with iTerm, I should hop back to Terminal and figure out my true preferences.
Derek Allard
May 20, 2007
3:06 pm
Well thought out and written Alex. I also tend to extend the idea of duplicating my setup to my code. Nearly every project I do starts with a CSS reset, and a few classes (.error, .notice, .success) that I know I’ll use. I just copy and paste the same CSS every time.
Alex
May 24, 2007
3:32 pm
Thanks Derek. That’s a good idea for CSS.
@Barry: I’ve been trying to modify my automation scripts to make them more generic but i’m having a bit of difficulty.
I never planned on sharing ‘that’ code with anyone lol. I guess this means I need to re-write them from scratch.