I’ve been experimenting with creating a few new handy plugins and view helpers to assist in rapid fire development with Zend Framework.
I came across a post recently which outlined how easy it is to output weather with php and Google Weather API
So I thought I would share how to create an easy to use view helper for outputting basic google weather.
Simply set this up in your plugins directory, making sure that you have the prefix setup in your bootstrap.
class Ace_View_Helper_GoogleWeather extends Zend_View_Helper_Abstract
public function __construct()
public function setView(Zend_View_Interface $view)
$this->view = $view;
public function googleWeather($location)
$xml = simplexml_load_file('http://www.google.com/ig/api?weather=' . $location);
$information = $xml->xpath("/xml_api_reply/weather/forecast_information");
$current = $xml->xpath("/xml_api_reply/weather/current_conditions");
$forecast_list = $xml->xpath("/xml_api_reply/weather/forecast_conditions");
$weatheroutput = "
<img src='http://www.google.com" . $current->icon['data'] . "' alt='weather' />
" . $current->temp_c['data'] . "° C,
" . $current->condition['data'] . "iooooooo
Then from your view script you can call it with this
<?= $this->GoogleWeather('Adelaide'); ?>