Skip to content

YII 1.1 plugin to request and render weather data from Weather Underground

License

Notifications You must be signed in to change notification settings

prokki/yii-wu-weather

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

README

Installation

Configuration

config/main.php

// application components
'components' => array(

[...]

  'wuweather' => array(
    "class"  => 'ext.yii-wu-weather.WuWeather',
    "apiKey" => 'YOUR_API_KEY',
    "cache"  => array(
      'lifetime' => 43200,     // in seconds, 43200 sec = 12 hours
      'distance' => 300,       // distance
      'unit'     => 'miles',   // [optional] distance in miles, default is meter 
    ),
),

Documentation

Requests

/** @var WuWeather $wuweather */
$wuweather = Yii::app()->wuweather;

$response = $wuweather->standardRequest()
->addFeature("alerts")
->addFeature("forecast")
->setLanguage("DL")
->setLocation(52.5050, 13.4050)
->request();

Render/Output

$this->getController()->widget('ext.yii-wu-weather.widgets.renderer.WuWeatherStandardForecastRenderer', array(
  'response' => WuWeatherStandardRequestJSONTransformer::Create()->transform($request->getResponse()),
));

#### Custom Templates

```php
$this->getController()->widget('ext.yii-wu-weather.widgets.renderer.WuWeatherStandardForecastRenderer', array(
  'response' => WuWeatherStandardRequestJSONTransformer::Create()->transform($request->getResponse()),
  'template' => 'ALIAS_TO_CUSTOM_TEMPLATE',
  'feature'  => 'forecast',                  // optional - to validate requested feature in the response
));

About

YII 1.1 plugin to request and render weather data from Weather Underground

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages