2017 © Pedro Peláez
 

symfony-bundle weather-underground

Symfony2 bundle for working with Weather Underground API.

image

suncat/weather-underground

Symfony2 bundle for working with Weather Underground API.

  • Tuesday, December 17, 2013
  • by suncat2000
  • Repository
  • 1 Watchers
  • 0 Stars
  • 1,505 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 1 Versions
  • 15 % Grown

The README.md

WeatherUndergroundBundle

Symfony2 bundle for working with Weather Underground API, (*1)

Introduction

This Bundle enables integration Weather Underground API with your Symfony 2 project., (*2)

Installation

Add this bundle and kriswallsmith Buzz library to composer.json in your project to require section:

...
    {
        "kriswallsmith/buzz": "0.7",
        "suncat/weather-underground": "dev-master"
    }
...

Add this bundle to your application's kernel:

//app/AppKernel.php
public function registerBundles()
{
    return array(
        // ...
        new SunCat\WeatherUndergroundBundle\WeatherUndergroundBundle(),
        // ...
    );
}

Configure the weather_underground service in your YAML configuration:

#app/config/config.yml
weather_underground:
    apikey: your_api_key

Full configuration

#app/config/config.yml
weather_underground:
    apikey: your_api_key
    format: json                                                # json/xml
    host_data_features: http://api.wunderground.com             # default: http://api.wunderground.com
    host_autocomlete: http://autocomplete.wunderground.com      # default: http://autocomplete.wunderground.com

Usage example

``` php, (*3)

<?php // src/Acme/YourBundle/Command/WUForecastCommand.php class WUForecastCommand extends ContainerAwareCommand { /** * @see Command */ protected function configure() { $this ->setName('weather_underground:forecast') ->setDescription('Import data forecast by cities from api.wunderground.com') ->addOption('city', 0, InputOption::VALUE_REQUIRED, 'City name') ->setHelp(<<weather_underground:forecast command import forecast data., (*4)

php app/console weather_underground:forecast --city=Moscow, (*5)

EOF ); }, (*6)

    /**
     * {@inheritdoc}
     */
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $wuApi = $this->getContainer()->get('weather_underground.data_features');
        $wuApi->setFeatures(array('forecast'));
        $cityName = $input->getOption('city');

        if(!$cityName){
            throw new \Exception('Enter city name');
        }

        $wuApi->setQuery('/Russia/' . $cityName, true);
        $data = $wuApi->getData();

        //
        // put your code
        //
    }

}

Run command: ``` php php app/console weather_underground:forecast --city=Moscow

Data Features examples

``` php $wuApi->setRequestData( array('forecast', 'geolookup'), // Features array('lang' => 'RU'), // Settings 'Russia/Moscow' // Query ); $data = $wuApi->getData();, (*7)


``` php $wuApi->setFeatures(array('forecast', 'geolookup')); // Features $wuApi->setQuery('Russia/Moscow', true); // Query $data = $wuApi->getData();

AutoComplete example

php $wuAutocomplete = $this->getContainer()->get('weather_underground.autocomplete'); $wuAutocomplete->setOptions(array('c' => 'RU', 'cities' => 1, 'query' => 'Mosc')); $data = $wuAutocomplete->getData();, (*8)

Weather Underground API Documentation

Data Features, (*9)

AutoComplete API, (*10)

The Versions

17/12 2013

dev-master

9999999-dev https://github.com/suncat2000/WeatherUndergroundBundle

Symfony2 bundle for working with Weather Underground API.

  Sources   Download

MIT

The Requires

 

The Development Requires

weather weather api wunderground weather underground api wunderground api