<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>LornaJane</title>
	
	<link>http://www.lornajane.net</link>
	<description>Lorna Jane Mitchell's Website</description>
	<lastBuildDate>Wed, 16 May 2012 08:47:10 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/lornajane" /><feedburner:info uri="lornajane" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>How the Web Looks to Me</title>
		<link>http://feedproxy.google.com/~r/lornajane/~3/jKW3R8-Q5HA/how-the-web-looks-to-me</link>
		<comments>http://www.lornajane.net/posts/2012/how-the-web-looks-to-me#comments</comments>
		<pubDate>Wed, 16 May 2012 08:47:10 +0000</pubDate>
		<dc:creator>lornajane</dc:creator>
				<category><![CDATA[tech]]></category>
		<category><![CDATA[accessilibility]]></category>
		<category><![CDATA[chrome]]></category>
		<category><![CDATA[keyboard navigation]]></category>

		<guid isPermaLink="false">http://www.lornajane.net/?p=1668</guid>
		<description><![CDATA[It feels like I've tried to field the question about how I can use the web without using a mouse (or trackpad or equivalent), without "pointing", multiple times in the last couple of weeks. The answer is quite visual so &#8230; <a href="http://www.lornajane.net/posts/2012/how-the-web-looks-to-me">Continue reading <span class="meta-nav">&#8594;</span></a><p>Lorna is an independent web development consultant, writer and trainer, open source project lead and community evangelist.  This post was originally published at <a href="http://www.lornajane.net">LornaJane</a></p>
]]></description>
			<content:encoded><![CDATA[<p>It feels like I've tried to field the question about how I can use the web without using a mouse (or trackpad or equivalent), without "pointing", multiple times in the last couple of weeks.  The answer is quite visual so I thought I'd share.  This is how the web looks to me:</p>
<p><a href="http://www.lornajane.net/wp-content/uploads/2012/05/chrome-keyboard-nav.png"><img src="http://www.lornajane.net/wp-content/uploads/2012/05/chrome-keyboard-nav-300x156.png" alt="" title="chrome-keyboard-nav" width="300" height="156" class="alignnone size-medium wp-image-1669" /></a></p>
<p>I navigate the web using <a href="https://chrome.google.com/webstore/detail/abcekjakjehkpheoaadhkjfcdodpjbgk">the Keyboard Navigation extension in Google Chrome</a>, which is what is adding all the little labels you see in the screenshot above.  Install the extension, and press comma.  The labels will pop up, then you type whichever character(s) show next to the thing you want to "click" on, and off you go.</p>
<p>It's super-simple, and easier to use than I expected.  Why don't you try it out on your own sites?  You'll get a sense of how the web looks from where I'm standing :)</p>
<p>Lorna is an independent web development consultant, writer and trainer, open source project lead and community evangelist.  This post was originally published at <a href="http://www.lornajane.net">LornaJane</a></p>
<img src="http://feeds.feedburner.com/~r/lornajane/~4/jKW3R8-Q5HA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.lornajane.net/posts/2012/how-the-web-looks-to-me/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.lornajane.net/posts/2012/how-the-web-looks-to-me?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=how-the-web-looks-to-me</feedburner:origLink></item>
		<item>
		<title>Speaking at OSCON 2012</title>
		<link>http://feedproxy.google.com/~r/lornajane/~3/R4fNAbpQdaw/speaking-at-oscon-2012</link>
		<comments>http://www.lornajane.net/posts/2012/speaking-at-oscon-2012#comments</comments>
		<pubDate>Mon, 14 May 2012 07:22:53 +0000</pubDate>
		<dc:creator>lornajane</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[conference]]></category>
		<category><![CDATA[oscon]]></category>
		<category><![CDATA[oscon12]]></category>
		<category><![CDATA[speaking]]></category>

		<guid isPermaLink="false">http://www.lornajane.net/?p=1665</guid>
		<description><![CDATA[In July, I'm speaking at OSCON. Actually I have a few interesting speaking engagements coming up, and I haven't got around to adding upcoming dates to my blog yet but I'll be at phpDay in Verona next week with a &#8230; <a href="http://www.lornajane.net/posts/2012/speaking-at-oscon-2012">Continue reading <span class="meta-nav">&#8594;</span></a><p>Lorna is an independent web development consultant, writer and trainer, open source project lead and community evangelist.  This post was originally published at <a href="http://www.lornajane.net">LornaJane</a></p>
]]></description>
			<content:encoded><![CDATA[<p>In July, I'm speaking at OSCON.  Actually I have a few interesting speaking engagements coming up, and I haven't got around to adding upcoming dates to my blog yet but I'll be at phpDay in Verona next week with a talk on API Design and DPC in Amsterdam in June with a tutorial on Web Services and a talk on what OAuth is actually for.</p>
<p>OSCON is special because I have always wanted to go and never imagined it would actually happen.  Every year I read the list of sessions from the year before, and decide that I absolutely must submit to the call for papers, regardless of how small I think my chances of being accepted are!  I've submitted a couple of times in the past, excluding last year because I was newly freelance (OSCON does not cover any speaker expenses at all, they just give you a conference pass.  That's kind of hard going for those of us self-funding halfway across the world, and last year, I just couldn't do it.  This year I still can't really justify it but I'm going anyway!)<span id="more-1665"></span></p>
<p>I have two talks, both of them brand new, and I'm excited about them both!</p>
<h3>PHP 5.4 Features You'll Actually Use</h3>
<p>When I told one of my local user groups (how excellent to have more than one local user group!) about this talk they said "that'll be a short talk" and I am a little worried they are right!  Cool new array syntax, traits, and a web server ... am I missing anything important?  To make this even easier and more fun, Rasmus has the slot immediately before mine and his abstract includes "a detailed review of new PHP 5.4 features".  I feel like a spare part and I haven't even written the talk yet!</p>
<h3>Get Some Rest: Best RESTful API Practices</h3>
<p>This one will be lots of fun, because I firmly believe in writing services that make users, rather than textbooks, very happy.  Which means that I do break the rules and I think there are times when that's acceptable.  I suspect that there will be heckling, flaming, and foaming at the mouth involved but hey, I'm not there to be popular!  Honestly, I love REST, I think it's possible to take it too far, and I'm only a little bit scared to say that in public :)</p>
<h3>OSCON Conversations</h3>
<p>OSCON does a cool thing where it opens the comments on a talk page immediately - which means that you can already go and ask questions, make requests, or leave comments on either my <a href="http://www.oscon.com/oscon2012/public/schedule/detail/23503">PHP 5.4 talk</a> or the <a href="http://www.oscon.com/oscon2012/public/schedule/detail/23508">RESTful one</a> and let me know what you do (and perhaps do NOT) want to hear.  If you're going to OSCON or are just interested in the topics, I'm interested to hear your thoughts, either over here in the comments or over on the talks themselves!</p>
<p>Lorna is an independent web development consultant, writer and trainer, open source project lead and community evangelist.  This post was originally published at <a href="http://www.lornajane.net">LornaJane</a></p>
<img src="http://feeds.feedburner.com/~r/lornajane/~4/R4fNAbpQdaw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.lornajane.net/posts/2012/speaking-at-oscon-2012/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.lornajane.net/posts/2012/speaking-at-oscon-2012?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=speaking-at-oscon-2012</feedburner:origLink></item>
		<item>
		<title>Using an Existing Vagrant Setup for PHP Development</title>
		<link>http://feedproxy.google.com/~r/lornajane/~3/_0nOlhfjIho/using-an-existing-vagrant-setup-for-php-development</link>
		<comments>http://www.lornajane.net/posts/2012/using-an-existing-vagrant-setup-for-php-development#comments</comments>
		<pubDate>Wed, 09 May 2012 06:09:14 +0000</pubDate>
		<dc:creator>lornajane</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[joind.in]]></category>
		<category><![CDATA[puppet]]></category>
		<category><![CDATA[tools]]></category>
		<category><![CDATA[vagrant]]></category>
		<category><![CDATA[vm]]></category>

		<guid isPermaLink="false">http://www.lornajane.net/?p=1660</guid>
		<description><![CDATA[I've been hearing great things about puppet, chef, vagrant, and friends for a while now, but since I work on my own I tend to either develop straight onto my ubuntu machine or grab an appropriate existing VM and use &#8230; <a href="http://www.lornajane.net/posts/2012/using-an-existing-vagrant-setup-for-php-development">Continue reading <span class="meta-nav">&#8594;</span></a><p>Lorna is an independent web development consultant, writer and trainer, open source project lead and community evangelist.  This post was originally published at <a href="http://www.lornajane.net">LornaJane</a></p>
]]></description>
			<content:encoded><![CDATA[<p>I've been hearing great things about <a href="http://puppetlabs.com/" target="_blank">puppet</a>, <a href="http://www.opscode.com/chef/" target="_blank">chef</a>, <a href="http://vagrantup.com/" target="_blank">vagrant</a>, and friends for a while now, but since I work on my own I tend to either develop straight onto my ubuntu machine or grab an appropriate existing VM and use that.  So I read about this brave new world of virtualisation but (as with most tools) they can be hard to introduce on your own, and I didn't.</p>
<p>Then I went to <a href="http://whiskyweb.co.uk">WhiskyWeb</a>, which had a hackathon.  I'm unclear on exactly what happened because my attention was elsewhere but it seems like <a href="http://m.twitter.com/JayTaph">@JayTaph</a> showed off puppet and vagrant to <a href="http://m.twitter.com/deizel">@deizel</a>*, who immediately built a vagrant setup for <a href="http://joind.in">joind.in</a>, which is an open source project that I'm currently leading.  With the shiny new technology all packaged for me, I decided it was time to take a look!<span id="more-1660"></span></p>
<h3>Starting the VM</h3>
<p>The goal is that a user can simply grab the code base and type a single command:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">vagrant up</pre></div></div>

<p>When you do this the first time, then a "base box" is downloaded and puppet installs the various packages that will be used to run your platform.  Once you have the base box, you can use it again with a different configuration; very handy for anyone working with similar-but-not-quite-identical projects.  The setup process goes beyond the platform and also sets up the application with appropriate configuration files, databases created and so on.  This is fabulous because if you break something, change platforms, or otherwise get into a tangle of any kind - you can just recreate your platform!</p>
<p>If you've run the virtual machine before, this command just starts the VM again so that you can use it.</p>
<h3>Puasing Between Sessions</h3>
<p>You probably don't want to leave the VM running all the time (I have a shiny new machine with enough RAM that I can if I want to, which is nice!), and just like any other virtual machine you can shut it off and restart it at the same point later on, using:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">vagrant <span style="color: #7a0874; font-weight: bold;">suspend</span></pre></div></div>

<p>What I like about this is that it's so simple :)</p>
<h3>Throw it All Away</h3>
<p>If for any reason, either you broke something, or you have new puppet config perhaps, you want to throw away your VM and start again, that's easy to do:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">vagrant destroy</pre></div></div>

<p>We keep the base box, but throw away the actual VM instance when we do the above.  This means that you get an entirely clean installation when you run <code>vagrant up</code> the next time, with everything reset to the way that it was.  All the settings are very configurable so if you do end up making any changes on the VM, you can also make them in the configuration so that the next time you create the VM anew, those changes will be included.</p>
<h3>Network Topology</h3>
<p>Something I really liked about this setup, in comparison to the way that I usually do virtual machines, is that the VM shares files with the host machine.  Joind.in is hosted on github, so I grab a copy of the repo, type <code>vagrant up</code>, and then just edit the files in the current directory as I normally would.  I'm a vim user, so editing files on virtual machines has never really bothered me, but if you use a desktop IDE then this feature will make a big difference to the way that you work with it - and even for vim users, this eliminates the need for copying of .vimrc files and swearing at distros that install one leg of vi and call it good!</p>
<p>The vagrant box also knows how to connect to itself, so to get shell access you simply need to ask for it:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">vagrant <span style="color: #c20cb9; font-weight: bold;">ssh</span></pre></div></div>

<p>I think especially if you have a bunch of machines running, or potentially running, because all your development uses these platforms, this approach becomes increasingly valuable as you don't have to keep tabs on hostnames or IP addresses.  When you are in the directory for this project, the command gives you access to this VM ... simple!</p>
<h3>Shiny New Tools</h3>
<p>It's always easiest to learn something new by looking over someone's shoulder (which is why I teach a tools course) and while I'm sure I'll be diving into configuring the virtual machines in detail over time, just having this setup to try has been a great way to get started and see how it could work, tweak a few things on my own copy and so on.  Personally I'm delighted to have come across vagrant in such an approachable way - if you want to have a play yourself, then feel free to clone the <a href="https://github.com/joindin/joind.in">joind.in repo on github</a> to take a look at what we have there.  Thanks again to all the fabulous contributors who make this project what it is and continue to educate me every day!</p>
<p><i>* I haven't figured out if it makes more sense to link to twitter or github when citing people who have done cool code-related things</i></p>
<p>Lorna is an independent web development consultant, writer and trainer, open source project lead and community evangelist.  This post was originally published at <a href="http://www.lornajane.net">LornaJane</a></p>
<img src="http://feeds.feedburner.com/~r/lornajane/~4/_0nOlhfjIho" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.lornajane.net/posts/2012/using-an-existing-vagrant-setup-for-php-development/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://www.lornajane.net/posts/2012/using-an-existing-vagrant-setup-for-php-development?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=using-an-existing-vagrant-setup-for-php-development</feedburner:origLink></item>
		<item>
		<title>Tips on Writing an API for a Smartphone App</title>
		<link>http://feedproxy.google.com/~r/lornajane/~3/cUXh1-YTG5U/tips-on-writing-an-api-for-a-smartphone-app</link>
		<comments>http://www.lornajane.net/posts/2012/tips-on-writing-an-api-for-a-smartphone-app#comments</comments>
		<pubDate>Thu, 03 May 2012 13:22:00 +0000</pubDate>
		<dc:creator>lornajane</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[advice]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[http]]></category>
		<category><![CDATA[mobile]]></category>
		<category><![CDATA[smartphone]]></category>

		<guid isPermaLink="false">http://www.lornajane.net/?p=1652</guid>
		<description><![CDATA[Yesterday, I saw this tweet: I have lots of advice for Olly (whom I know personally) but there's no way it will fit into a tweet! So here it is, in rather longer form :) Be Consistent Whatever data format &#8230; <a href="http://www.lornajane.net/posts/2012/tips-on-writing-an-api-for-a-smartphone-app">Continue reading <span class="meta-nav">&#8594;</span></a><p>Lorna is an independent web development consultant, writer and trainer, open source project lead and community evangelist.  This post was originally published at <a href="http://www.lornajane.net">LornaJane</a></p>
]]></description>
			<content:encoded><![CDATA[<p>Yesterday, I saw this tweet:</p>
<div class="quotedtweet" id="tw197668987352530944" style="background-color:#eef;padding:5px;margin-bottom:5px">
	<div class="tw_user-info" style="padding:10px 10px 5px 0;float:left;text-align:center;width:100px;">
		<div class="tw_thumb">
			<a href="http://twitter.com/bunoire14" title="Olly Warren" class="quoting_pic" rel="external"><img src="http://img.tweetimag.es/i/bunoire14_n" alt="bunoire14" /></a>
		</div>
		<div class="tw_screen-name">
			<em><a href="http://twitter.com/bunoire14" title="Twitter page : Olly Warren" rel="external">bunoire14</a></em>
		</div>
		<div class="tw_full-name">
			<strong>(Olly Warren)</strong>
		</div>
	</div>
	<div class="tw_content" style="float: left; width: 500px; font: 20pt Georgia, Verdana, sans-serif; font-style: normal;">
		<div class="tw_entry-content">
				<a href="http://www.twitter.com/lornajane" rel="external">@lornajane</a> <a href="http://www.twitter.com/nabeels" rel="external">@nabeels</a> tips on starting to write an API to interact with Smartphone App?? :-s

		</div>
	</div>
	<div style="clear: both; text-align: left;font-style:italic;margin-left:110px">
		<p class="tw_meta tw_entry-meta" style="margin: 0;padding-top:5px">
			<small>
				<span>On <a href="http://twitter.com/bunoire14/status/197668987352530944" rel="external">2-5-2012 12:48:53</a></span> 
				<span>from <a href="http://itunes.apple.com/us/app/twitter/id409789998?mt=12" rel="nofollow">Twitter for Mac</a></span> 
				<span> in reply to Lorna Mitchell</span>
			</small>
		</p>
	</div>
</div>
<p>I have lots of advice for Olly (whom I know personally) but there's no way it will fit into a tweet!  So here it is, in rather longer form :)<br />
<span id="more-1652"></span></p>
<h3>Be Consistent</h3>
<p>Whatever data format you pick, whatever app you are building, whichever approach you choose, <b>be consistent</b>.  Your whole API should call things by the same name, use the same validation rules for everything, and accept parameters in the same order.  Every time.  Look out in particular for things like singular/plural names, mixing case and parameters which are sometimes optional.</p>
<h3>Fail Really Really Excellently</h3>
<p>Things will go wrong.  This is the way the world works in general, and on the web in particular.  Requests sometimes don't arrive, or the responses don't.  Disks fill up, databases fall offline, all kinds of weird stuff does happen.  All that matters is how you deal with it.</p>
<p>Make all your errors arrive in the <strong>same format as the successful response</strong> would have.  This means that the client can parse it and understand what is there.  If you feed HTML into something that wasn't expecting it, something unexpected will happen (actually PHP's <code>json_decode()</code> will cause PHP to segfault if you try hard enough).</p>
<p>Give meaningful error messages.  This allows users to help themselves, continue to use your API, hopefully learn to love it - and all without having to bother you in the process.  This is the holy grail of API creation!</p>
<h3>Keep It Tidy</h3>
<p>A Small API is easy to maintain and support, so try to keep your APIs as minimal as possible.  Only write functionality that is really needed.  Make things flexible so that clients can ask for more or fewer records than the default (especially if the data sets can get large!), and get the result set sorted sensibly - it's very expensive to do those kinds of operations on any kind of large data set on a small device.</p>
<p>Keeping this small is also keeping things simple, and the <a href="https://en.wikipedia.org/wiki/KISS_principle" target="_blank">KISS principle</a> is good advice for all areas of software design.</p>
<h3>The Actual Advice</h3>
<p>For a non-novice programmer, an API is a project that is absolutely approachable.  For sending data to a smart phone, I'd recommend the following:</p>
<ul>
<li><strong>JSON format</strong> - it's lightweight, easy to parse, and also relatively easy to debug if you need to</li>
<li><strong>RPC style</strong> - REST is much cooler, but it's hard to get started with if you haven't used it before, and bad REST just gets everyone upset.  You already know how to declare and call a function - so make your API along those lines.  Look at <a href="https://en.wikipedia.org/wiki/JSON-RPC">wikipedia's JSON-RPC page</a> for some ideas</li>
<li>Make sure you <strong>understand HTTP</strong> headers and status codes, and use them!  Use Accept and Content-Type for sorting out data formats, status codes to say if things went well or not.
<li>I feel like there should be more advice here ... please add a comment if you know what else I should be telling Olly!</li>
</ul>
<h3>Tools to Help You</h3>
<p>You'll be doing a lot of debugging, <code>print_r($_SERVER)</code> is a good place to start with understanding what requests came in.  Use <a href="http://www.wireshark.org/">wireshark</a> to make sure that you are sending and receiving what you think you are send and receiving.  If you need to debug output but doing so breaks your client because it sends nonsense in the data format, use <code>error_log</code> instead.</p>
<p>Most of all, know this: <strong>if you can already build a website, you can build an API</strong>.  Good luck :)</p>
<p>Lorna is an independent web development consultant, writer and trainer, open source project lead and community evangelist.  This post was originally published at <a href="http://www.lornajane.net">LornaJane</a></p>
<img src="http://feeds.feedburner.com/~r/lornajane/~4/cUXh1-YTG5U" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.lornajane.net/posts/2012/tips-on-writing-an-api-for-a-smartphone-app/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		<feedburner:origLink>http://www.lornajane.net/posts/2012/tips-on-writing-an-api-for-a-smartphone-app?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=tips-on-writing-an-api-for-a-smartphone-app</feedburner:origLink></item>
		<item>
		<title>Taking on a Database Change Process</title>
		<link>http://feedproxy.google.com/~r/lornajane/~3/1PYYr-0JNHc/taking-on-a-database-change-process</link>
		<comments>http://www.lornajane.net/posts/2012/taking-on-a-database-change-process#comments</comments>
		<pubDate>Mon, 30 Apr 2012 08:12:54 +0000</pubDate>
		<dc:creator>lornajane</dc:creator>
				<category><![CDATA[tech]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database version control]]></category>
		<category><![CDATA[deployment]]></category>
		<category><![CDATA[process]]></category>
		<category><![CDATA[tools]]></category>

		<guid isPermaLink="false">http://www.lornajane.net/?p=1647</guid>
		<description><![CDATA[I wrote recently about deployment and I got some followup questions about managing database changes when you've got multiple versions of code hanging around. There are two things you need to come to terms with: There is no silver bullet &#8230; <a href="http://www.lornajane.net/posts/2012/taking-on-a-database-change-process">Continue reading <span class="meta-nav">&#8594;</span></a><p>Lorna is an independent web development consultant, writer and trainer, open source project lead and community evangelist.  This post was originally published at <a href="http://www.lornajane.net">LornaJane</a></p>
]]></description>
			<content:encoded><![CDATA[<p>I wrote recently about deployment and I got some <a href="http://www.lornajane.net/posts/2012/we-dont-know-deployment-a-4-step-remedy#comment-4592">followup</a> <a href="http://www.lornajane.net/posts/2012/we-dont-know-deployment-a-4-step-remedy#comment-4524">questions</a> about managing database changes when you've got multiple versions of code hanging around.</p>
<p>There are two things you need to come to terms with:</p>
<ul>
<li>There is no silver bullet</li>
<li>Rigid process is required</li>
</ul>
<p><span id="more-1647"></span></p>
<p>If you're still reading, then I assume I haven't scared you off with the above, so let's get into the more practical side of things and look at the steps to follow for coherent database versioning ...</p>
<h3>Hands Off The Database</h3>
<p>If you are serious about keeping track of the changes to your database, then you will <strong>never make another change</strong> to it manually.  Never.  Not even the test or development databases, nor "to just quickly try" something.</p>
<p>When you want to make a change, make a <strong>patch script</strong>.  Then when you run it against your development database and it works, you know exactly how to replicate the same excellent manoeuvre against any other platform that needs it - including sharing it with other developers in your team.  The patches are included in your source control, but ideally not inside your web root (you don't want to serve these to the outside world!).</p>
<h3>Identifying Patches</h3>
<p>I wrote a while ago about <a href="http://www.lornajane.net/posts/2010/Simple-Database-Patching-Strategy">how to work with database patches</a>, and I'm using basically the same approach on most of my projects today.  Each patch file contains: a comment on what this file does, the change(s) to make, and another SQL statement that records that this patch has been run for this database, and when that happened (I had a phase of recording only "latest patch" information but I now prefer a log of what was run and when).</p>
<p>What you name your patch files is up to you - I like sequential numbers but of course they do sometimes collide when branches are merged together so human intervention will be needed in that situation.  We are smart and can handle this :)</p>
<p>Some changes can take more than one deploy to enforce - for example I recently deployed a major change to one of my own sites, which changed the database schema enormously and needed me to move data from one table to another.  I wrote a patch to do that, and a separate one to drop the old copies of the data.  The first patch was deployed with the relevant code changes, but the other patch is currently called "patch-future.sql" - it will be deployed once I'm certain the change is live and I won't need to roll it back (more on rollbacks in a moment).</p>
<h3>Make It Painless</h3>
<p>This is really a general piece of advice for deployment and other development process: <strong>make your preferred path the easiest choice</strong>.  This does mean a bit of time automating the processes, but I have yet to regret spending time on these tasks.  For database patching we'll write a script which will look at the database and the patch files, and run any that haven't already run.  Anyone pulling in these changes only needs to run one script, and you can automate that step in your deployment stages.</p>
<p>Do observe this one golden rule: <b>never edit a patch file </b>after it has been pushed!</p>
<h3>Tools for Database Patching</h3>
<p>There are lots of tools that wrap up what you've seen here; but the basics are the same:</p>
<ol>
<li>Do not touch the database directly</li>
<li>Write patch files</li>
<li>Record what patches are applied</li>
<li>Automate patching</li>
</ol>
<p>I've used or heard good things about <a href="http://dbdeploy.com/">DbDeploy</a> which integrates with <a href="http://phing.info">Phing</a> very nicely, Rob Allen's <a href="https://github.com/akrabat/Akrabat">Akrabat_Db_Schema_Manager</a> for ZF, so either of those is worth a look and if you have more recommendations, then please share them in the comments!</p>
<h3>Rolling Back</h3>
<p>As a final note, I will mention rolling back of database changes; this is a really tricky one and I haven't got any solutions that I think have been worth the hassle.  Personally I like to do lots and lots of incremental changes, deploying as often as humanly possible (often several times each day) so large breakages are less likely.  Academic theory says that for every forward patch, you should have an undo one, but practical experience tells me that this makes it harder to finish features and the rollbacks are almost never used.  For my own projects (none of them especially high traffic or commercially critical) I have undertaken to run without any rollback scripts required.  If the unthinkable happens (and it will, one day!), I will write the script to mend the damage as a new patch and deploy it.  How you choose to approach this issue will vary hugely for different scenarios - what do you do?</p>
<p>Lorna is an independent web development consultant, writer and trainer, open source project lead and community evangelist.  This post was originally published at <a href="http://www.lornajane.net">LornaJane</a></p>
<img src="http://feeds.feedburner.com/~r/lornajane/~4/1PYYr-0JNHc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.lornajane.net/posts/2012/taking-on-a-database-change-process/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		<feedburner:origLink>http://www.lornajane.net/posts/2012/taking-on-a-database-change-process?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=taking-on-a-database-change-process</feedburner:origLink></item>
		<item>
		<title>Community Wisdom: A Training Budget of Zero</title>
		<link>http://feedproxy.google.com/~r/lornajane/~3/Lm_NVWunaOs/community-wisdom-a-training-budget-of-zero</link>
		<comments>http://www.lornajane.net/posts/2012/community-wisdom-a-training-budget-of-zero#comments</comments>
		<pubDate>Fri, 27 Apr 2012 10:15:55 +0000</pubDate>
		<dc:creator>lornajane</dc:creator>
				<category><![CDATA[work]]></category>
		<category><![CDATA[professional development]]></category>
		<category><![CDATA[statistics]]></category>

		<guid isPermaLink="false">http://www.lornajane.net/?p=1644</guid>
		<description><![CDATA[I recently wrote a post about what to do when your training budget is zero, and included a poll for what advice others would give. It got 42 votes, which I thought was an indication that I should share the &#8230; <a href="http://www.lornajane.net/posts/2012/community-wisdom-a-training-budget-of-zero">Continue reading <span class="meta-nav">&#8594;</span></a><p>Lorna is an independent web development consultant, writer and trainer, open source project lead and community evangelist.  This post was originally published at <a href="http://www.lornajane.net">LornaJane</a></p>
]]></description>
			<content:encoded><![CDATA[<p>I recently wrote a post about <a href="http://www.lornajane.net/posts/2012/5-things-to-do-with-a-training-budget-of-zero">what to do when your training budget is zero</a>, and included a poll for what advice others would give.  It got 42 votes, which I thought was an indication that I should share the results!  Here it is:</p>
<p><script src="http://twtpoll.com/js/ibadge.js" type="text/javascript"></script><br />
<iframe src="http://twtpoll.com/badge/if/?twt=p2sqjo&#038;b=1&#038;bt=1" width="100%" height="400" frameborder="0" scrolling="no" name="twpw_if" id="twpw_if" onLoad="TwtpwFm.registerFrame(this);">Your browser doesn't support iFrames :( Vote for this poll <a href="http://twtpoll.com/p2sqjo"  title="here" target="_blank">here</a>.</iframe><br />
<span id="more-1644"></span><br />
Almost half of people recommended attending a user group, which makes me very happy. Organising user groups can be a bit of a drag, you need to be available on the same dates every month, book venues, round up speakers, and so on.  It's something I've always enjoyed and I tend to "tourist" around and visit any UK groups that I can get to (or indeed any further afield if my schedule permits it), so I was delighted to see so many people suggesting this as a good way to advance.  It's also a good night out usually, when I saw someone tweet about my next talk being in Manchester rather than Leeds, I had no hesitation in telling him:</p>
<div class="quotedtweet" id="tw195480399760195584" style="background-color:#eef;padding:5px;margin-bottom:5px">
	<div class="tw_user-info" style="padding:10px 10px 5px 0;float:left;text-align:center;width:100px;">
		<div class="tw_thumb">
			<a href="http://twitter.com/lornajane" title="Lorna Mitchell" class="quoting_pic" rel="external"><img src="http://img.tweetimag.es/i/lornajane_n" alt="lornajane" /></a>
		</div>
		<div class="tw_screen-name">
			<em><a href="http://twitter.com/lornajane" title="Twitter page : Lorna Mitchell" rel="external">lornajane</a></em>
		</div>
		<div class="tw_full-name">
			<strong>(Lorna Mitchell)</strong>
		</div>
	</div>
	<div class="tw_content" style="float: left; width: 500px; font: 20pt Georgia, Verdana, sans-serif; font-style: normal;">
		<div class="tw_entry-content">
				<a href="http://www.twitter.com/TomWade" rel="external">@TomWade</a> just come and get the train over with us! I can promise you a good night out :)

		</div>
	</div>
	<div style="clear: both; text-align: left;font-style:italic;margin-left:110px">
		<p class="tw_meta tw_entry-meta" style="margin: 0;padding-top:5px">
			<small>
				<span>On <a href="http://twitter.com/lornajane/status/195480399760195584" rel="external">26-4-2012 11:52:13</a></span> 
				<span>from <a href="http://www.floodgap.com/software/ttytter/" rel="nofollow">TTYtter</a></span> 
				<span> in reply to <a href="http://twitter.com/TomWade/status/195478982165143552" rel="external">Tom Wade</a></span>
			</small>
		</p>
	</div>
</div>
<p>Lots of other people were in favour of using free resources, and given just <i>how</i> excellent the free resources are in my area of expertise, PHP, that's absolutely sound advice.  I do own a few books, but mostly I just ask google for whatever it was that I needed to know next - and I'll find it, on a blog, or <a href="http://stackoverflow.com">stackoverflow</a>, or something.</p>
<p>Paying for your own conferences/training was recognised as important by quite a few people, and I must say that this is certainly where I came from.  The visibility let me get a job where I could attend more of these things, but at the start, I was just an attendee, tagging along to events and finding out more about the world.</p>
<p>Most interesting, perhaps, were the people who answered "other" and gave advice of their own:</p>
<ul>
<li>Speak at a conference</li>
<li>leave the company for one which takes you seriously</li>
<li>Work on a challenging personal project</li>
</ul>
<p>I think I've done all of the above, and all of them have definitely brought rewards in ways that I couldn't even imagine.  Thanks to all of you for the advice (I can't figure out how to see who recommended what, so we'll call it community wisdom) and for voting - definitely food for thought.</p>
<p>Lorna is an independent web development consultant, writer and trainer, open source project lead and community evangelist.  This post was originally published at <a href="http://www.lornajane.net">LornaJane</a></p>
<img src="http://feeds.feedburner.com/~r/lornajane/~4/Lm_NVWunaOs" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.lornajane.net/posts/2012/community-wisdom-a-training-budget-of-zero/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.lornajane.net/posts/2012/community-wisdom-a-training-budget-of-zero?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=community-wisdom-a-training-budget-of-zero</feedburner:origLink></item>
		<item>
		<title>We Don't Know Deployment: A 4-Step Remedy</title>
		<link>http://feedproxy.google.com/~r/lornajane/~3/ReZUtIUkhuA/we-dont-know-deployment-a-4-step-remedy</link>
		<comments>http://www.lornajane.net/posts/2012/we-dont-know-deployment-a-4-step-remedy#comments</comments>
		<pubDate>Wed, 18 Apr 2012 07:51:46 +0000</pubDate>
		<dc:creator>lornajane</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[tech]]></category>
		<category><![CDATA[advice]]></category>
		<category><![CDATA[best practice]]></category>
		<category><![CDATA[deployment]]></category>
		<category><![CDATA[ftp]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[hg]]></category>
		<category><![CDATA[phing]]></category>
		<category><![CDATA[source control]]></category>
		<category><![CDATA[svn]]></category>

		<guid isPermaLink="false">http://www.lornajane.net/?p=1600</guid>
		<description><![CDATA[Someone emailed me recently, having read my book and wanting some advice. Here's a snippet of his email: So here's my problem. We dont know deployment. We work from same copy on one test server through ftp and then upload &#8230; <a href="http://www.lornajane.net/posts/2012/we-dont-know-deployment-a-4-step-remedy">Continue reading <span class="meta-nav">&#8594;</span></a><p>Lorna is an independent web development consultant, writer and trainer, open source project lead and community evangelist.  This post was originally published at <a href="http://www.lornajane.net">LornaJane</a></p>
]]></description>
			<content:encoded><![CDATA[<p>Someone emailed me recently, having read <a href="http://www.lornajane.net/posts/lj_publications/php-master-write-cutting-edge-code" title="PHP Master: Write Cutting-Edge Code">my book</a> and wanting some advice.  Here's a snippet of his email:</p>
<blockquote><p><i><br />
So here's my problem.<br />
We dont know deployment.  We work from same copy on one test server through ftp and then upload live on FTP.</p>
<p>We have some small projects and some big collaborative projects.</p>
<p>We host all these projects on our local shared computer which we call test server.<br />
All guys take code from it and return it there. We show our work to clients on that machine and then upload that work to live ftp.</p>
<p>Do you think this is a good scenario or do we make this machine a dev server and introduce a staging server for some projects as well?</i></p></blockquote>
<p>I wrote him a reply with some suggestions (and my consulting rate) attached, and we had a little email exchange about some improvements that could fit in with the existing setup, both of the hardware and of the team skills.  Then I started to think ... he probably isn't the only person who is wondering if there's a better way.  So here's my advice, now with pictures! <span id="more-1600"></span></p>
<h3>Starting Point</h3>
<p>This is basically the place we begin from:</p>
<p><img src="http://www.lornajane.net/wp-content/uploads/2012/04/existing.png" alt="" title="diagram of the starting point" width="296" height="184" class="alignnone size-full wp-image-1617" /></p>
<p>The code lives on this staging server, when you need to make a change, you copy it onto your own machine, make the change, and put it back on the staging server.  From here, it can be checked over before it is put onto the live machine over FTP.</p>
<p>The first thing to say is: this does work, as long as you follow the process exactly.  But I was asked if I thought there was a better way, and I think there is.  When I work with a setup like this, there is always a moment where I have no idea if I just copied over something, or forgot to copy over something, or ... you get the picture.</p>
<h3>Step 1: Source Control</h3>
<p><strong>Use source control</strong>.  That's the best advice I can give anyone.  Use a hosted solution, install your own, pick Subversion or Git or Mercurial, I really don't care.  But use source control.</p>
<p>Here's the diagram with the source control in place, using SVN as an example (but it makes little difference what kind of source control you pick)</p>
<p><a href="http://www.lornajane.net/wp-content/uploads/2012/04/step1.png"><img src="http://www.lornajane.net/wp-content/uploads/2012/04/step1.png" alt="" title="step1" width="568" height="259" class="alignnone size-full wp-image-1619" /></a></p>
<p>Hardly anything has moved, but we've added a piece to the middle of the puzzle.  At this point, there's a central repository where things are always kept, and always backed up.  We have a history of changes, and can see who changed what.  The developers can collaborate on larger changesets, and those changes can be committed to the repository even before they are ready to be placed onto the staging server, so you are much less likely to lose code when a hard drive dies.</p>
<p>To get the code from the repository to the staging and live servers, we can export a clean copy of code each time and upload that using FTP (or go one step further, SFTP).  If you really must check out from source control repositories onto public servers, then make absolutely sure you are not serving the metadata that the source control product uses - since this is only step 1, that would be OK (but keep reading).</p>
<h3>Step 2: Branches</h3>
<p>Now we've gone to all the trouble of implementing a source control solution, we may as well make the most of the features that are now available to us.  This means it is time to learn to <b>branch</b>.  A branch is just another copy of the code, but isolated from the first one.  Using branches means you can:</p>
<ul>
<li>always have an exact copy of the current live code available</li>
<li>work on more than one feature (or bug fix) at once</li>
</ul>
<p>You would use the same setup as above, but branching means you are able to do a great many more things without any fear of who changed what or whether you can commit without hurting things.</p>
<p>I could write <i>another</i> thousand words about branching, but I won't (well, unless you ask very nicely, and even then it will be written another time).  Instead, look around for some resources for whichever platform you chose: the <a href="http://svnbook.red-bean.com/en/1.1/ch04.html">Red Bean Book</a> is a great place to start.</p>
<h3>Step 3: Automated Deployment</h3>
<p>This is the jewel in the crown, especially if you run multiple sites.  If you only run one site, no matter how complicated it is, you will eventually learn to get the deployment mostly right, most of the time.  With multiple sites, they will all have differences and they will take turns to bite you when you least expect it (or, more likely, on Friday afternoon when you are trying to do three other things before pub o'clock).  Automated deployment means <b>fast, repeatable, painless deployment</b> every single time.</p>
<p>To deploy, you probably need some kind of build process.  I've got it here as a separate piece of the system as it's conceptually separate, but it could easily be as simple as a few scripts running on a spare box in the office (which might also run your SVN, for example), you don't need anything fancy.</p>
<p><img src="http://www.lornajane.net/wp-content/uploads/2012/04/step3.png" alt="" title="step3" width="568" height="355" class="alignnone size-full wp-image-1622" /></p>
<p>There's the build server, right in the middle.  When changes are available in the version control system, the build server will know about them.  When you are ready, you ask the build server to deploy the relevant code to either live or staging, and it does that.  Nobody else touches live.  For any reason.  If they do, their changes get lost on the next deploy - and anyway, automated deployment is so easy that there's no reason not to use the process!</p>
<p>Exactly how the code gets deployed is up to you; personally though I like <a href="http://phing.info">phing</a>, which comes with lots of tasks for dealing with source control and PHP-specific tools built in.  It's relatively easy to get started with and you will set it up to follow the process which is currently documented on your company wiki (it is documented, right??).  Mine goes something along the lines of:</p>
<ol>
<li>export files from source control</li>
<li>compress files</li>
<li>transfer files to server</li>
<li>log into server, uncompress files</li>
<li>deal with database changes, upload files, and anything else which needs special attention</li>
<li>make the new code live by changing the symlink that your docroot points to</li>
</ol>
<p>Yours may be a bit different, but this is all pretty straightforward to set up with phing, or you can write your own scripts if you prefer.</p>
<h3>Step 4: For Bonus Points</h3>
<p>By the time you've got source control and a build step set up, you have the basis for all of the cool tools - so try them out!  Your "build server" can run other scripts as well, which makes it really a continuous integration server.  You can get it to respond to changes in your version control and perhaps run some tests or generate the API documentation.  You can add all kinds of preparation into the deployment steps, minifying JavaScript or CSS, stopping and starting worker processes; anything you can imagine!</p>
<h3>Better than FTP</h3>
<p>I'm not advocating using cool tools just for the hype; the recommendations here are the ones I use to protect myself from my own mistakes, hardware failure, projects with changing requirements, bosses with short memory spans, and all the other things that are part of everyday work.  With branches in version control and some automated deployment, I can create and publish multiple changes in little more time than it takes me to write the actual code - which is really  what I'm interested in!</p>
<p>Does this resemble your setup?  Would you have given the same advice if you received this email?  Let me know in the comments! (I'm sending a link to my original enquirer so it would be useful for him to hear your thoughts!)</p>
<p>Lorna is an independent web development consultant, writer and trainer, open source project lead and community evangelist.  This post was originally published at <a href="http://www.lornajane.net">LornaJane</a></p>
<img src="http://feeds.feedburner.com/~r/lornajane/~4/ReZUtIUkhuA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.lornajane.net/posts/2012/we-dont-know-deployment-a-4-step-remedy/feed</wfw:commentRss>
		<slash:comments>18</slash:comments>
		<feedburner:origLink>http://www.lornajane.net/posts/2012/we-dont-know-deployment-a-4-step-remedy?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=we-dont-know-deployment-a-4-step-remedy</feedburner:origLink></item>
		<item>
		<title>Apache Config: .htaccess or Virtual Hosts?</title>
		<link>http://feedproxy.google.com/~r/lornajane/~3/rVHZLSJqGOg/apache-config-htaccess-or-virtual-hosts</link>
		<comments>http://www.lornajane.net/posts/2012/apache-config-htaccess-or-virtual-hosts#comments</comments>
		<pubDate>Thu, 12 Apr 2012 07:27:09 +0000</pubDate>
		<dc:creator>lornajane</dc:creator>
				<category><![CDATA[tech]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[config]]></category>
		<category><![CDATA[deployment]]></category>

		<guid isPermaLink="false">http://www.lornajane.net/?p=1610</guid>
		<description><![CDATA[How to set apache configuration for your web projects? Some settings have to be in the main apache config or in a virtual host, but for many others you have two good choices; either use an .htaccess file, or place &#8230; <a href="http://www.lornajane.net/posts/2012/apache-config-htaccess-or-virtual-hosts">Continue reading <span class="meta-nav">&#8594;</span></a><p>Lorna is an independent web development consultant, writer and trainer, open source project lead and community evangelist.  This post was originally published at <a href="http://www.lornajane.net">LornaJane</a></p>
]]></description>
			<content:encoded><![CDATA[<p>How to set apache configuration for your web projects?  Some settings have to be in the <a href="http://httpd.apache.org/docs/2.2/configuring.html" target="_blank">main apache config or in a virtual host</a>, but for many others you have two good choices; either use an <code><a href="http://httpd.apache.org/docs/2.2/configuring.html#htaccess">.htaccess</a></code> file, or place the setting in the vhost (virtual host) configuration.  Which one you choose depends largely on your project setup, let's look at each in turn:</p>
<h3>The .htaccess File</h3>
<p>The biggest item in favour of an <code>.htaccess</code> file is that it belongs in your webroot, and can be checked in to your version control tool as part of your project.  Particularly if your project is going to be installed by multiple people on multiple platforms, this can be a very easy way to get development copies of code set up very quickly and for it to be easy for developers to see what should be in their <code>.htaccess</code> files.  </p>
<p>With version control, you can also send new <code>.htaccess</code> configuration through by updating your copy of the file - but whether this is a strength or a weakness is up to you to judge!  If everyone needs different path settings, for example, and is constantly overwriting your <code>.htaccess</code> file, that's not a particularly excellent setup!  Previously I've distributed a sample <code>.htaccess</code> file with a different file name, and added <code>.htaccess</code> itself to the ignore list of the version control tool.</p>
<h3>The Virtual Host</h3>
<p>Putting settings in the virtual host allows an easy way to configure the environment on a per-server basis, and not to accidentally deploy an incorrect setup.  You could still distribute a sample vhost setup for people to use as their basis, exactly as you could for <code>.htaccess</code>.</p>
<p>The biggest reason for using the virtual host, especially on a production server, is that using <code>.htaccess</code> incurs a performance penalty.  When you use <code>.htaccess</code>, apache looks in the current directory for an <code>.htaccess</code> file to use.  It also searches in the parent directory ... and that parent directory's parent directory ... and so on, up to the root of the file system.  Imagine doing that on every request to a system under load!</p>
<h3>Which To Choose?</h3>
<p>It completely depends.  At one end of the system, the open source project that will be set up on a relatively large number of systems by potentially inexperienced people - you'd probably choose <code>.htaccess</code>.  For a large-scale, live platform deployment, use the apache settings themselves (a virtual host for a server which runs multiple sites - apache's own settings for a server which only hosts a single site).  Where are you on the scale and which will you choose?</p>
<p>Lorna is an independent web development consultant, writer and trainer, open source project lead and community evangelist.  This post was originally published at <a href="http://www.lornajane.net">LornaJane</a></p>
<img src="http://feeds.feedburner.com/~r/lornajane/~4/rVHZLSJqGOg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.lornajane.net/posts/2012/apache-config-htaccess-or-virtual-hosts/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://www.lornajane.net/posts/2012/apache-config-htaccess-or-virtual-hosts?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=apache-config-htaccess-or-virtual-hosts</feedburner:origLink></item>
	</channel>
</rss>

