Geocodes Made Easy

Using my Google Maps API key I can geocode almost anything*. And with Zend Framework, it’s f’n damn simple! Zend_Loader::loadClass(‘Zend_Rest_Client’); $rest = new Zend_Rest_Client(‘http://maps.google.com/maps/geo’); //?q=1600+Amphitheatre+Parkway,+Mountain+View,+CA&output=json&oe=utf8&sensor=true_or_false&key=your_api_key $rest->key(‘YOUR_API_KEY’); $rest->q(‘1600 Amphitheatre Parkway, Mountain View, CA’); $rest->output(‘xml’); $rest->oe(‘utf8’); $result = $rest->get(); // the whole $result is a SimpleXML object print_r((string)$result->Response->Placemark->Point->coordinates); And that’s it.  Save the results someplace useful so […]

Using __call() in your controller to render magic content.

I was writing a basic CMS-type system and I was getting a bit annoyed with long urls, ie: /index/content/page/something, when I really just wanted /content/something – so I thought to myself, “self, why don’t you use __call() and just magically handle the incoming actions? Well, self, that was a brilliant idea. function __call($method, $params) { […]

Posting Defaults for Checkboxes

I was playing around with Zend_Form a little while ago and I realized they did something neat with checkboxes. Everytime I created a checkbox, Zend made two. <input id=”optInDefault” name=”optIn” type=”hidden” value=”n” /> <input id=”optIn” name=”optIn” type=”checkbox” value=”y” /> One hidden, and one not.  This is handy because when the user doesn’t check it – […]

Zend Framework, Rewrite Rules, Apache

Most of the Zend Framework documentation I’ve read recommends a rewrite rule that looks something like this: RewriteEngine on RewriteRule !\.(swf|js|ico|gif|jpg|png|css)$ index.php Why not use a more elegant rule that looks like this: RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule .* index.php This rule basically says: If it’s not an existing file, and it’s not […]

Zend Framework 1.6, and more.

Zend released version 1.6 of their framework just a short while ago and I’ve been reviewing a lot of the changes.  As it turns out this framework is becoming quite large and diverse in what it can do.  Some of the newer features that interest me: Saving sessions to a database table. Dojo integration Captcha […]