2017 © Pedro Peláez
 

library weather-bundle

Weather Bundle of Symfony

image

pianosolo/weather-bundle

Weather Bundle of Symfony

  • Thursday, August 3, 2017
  • by PianoSolo
  • Repository
  • 1 Watchers
  • 1 Stars
  • 692 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 7 Versions
  • 18 % Grown

The README.md

PianoSolo Weather Bundle

The PianoSolo Weather Bundle is a Symfony2 project to get data from weather services. Currently bringing data from OpenWeatherMap api. PianoSolo Weather Bundle has got different way of using the weather data in your project. One as a Twig Extension and the second one as a service which brings all weather information from api as object., (*1)

Latest Stable Version License Downloads, (*2)

Installation

1-) Tell composer to download by running the command:, (*3)

composer require pianosolo/weather-bundle

2-) Add the bundle to AppKernel, (*4)

<?php
// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new PianoSolo\WeatherBundle\PianoSoloWeatherBundle(),
    );
}

3-) Add configuration to config.yml file, (*5)

piano_solo_weather:
    api_key: "YourApiKey" # Required (OpenWeatherMap Api Key)
    options:
        download_csv: false # Default True
        cache: true # Default False (To use cache the system needs Php-Apc cache)

To install Php-Apc rund this command:, (*6)

sudo apt-get install php-apc

4-) Add the routing for CSV Downloading to routing.yml, (*7)

pianosolo_weather:
    resource: "@PianoSoloWeatherBundle/Resources/config/routing.yml"

Usage

Basic Usage

Gets data from OpenWeatherMap api. Check api for usage: http://openweathermap.org/api, (*8)

Get data with type. Add url parameters in array. ``` php $weatherService = $this->get('pianosolo.weather'); $weather = $weatherService->getData('forecast', array('id' => 800, 'lat' => 52.52, 'lon' => 13.41));, (*9)


Or get data with city name and type ``` php $weatherService = $this->get('pianosolo.weather'); $weather = $weatherService->getCityData('weather', 'Berlin', array('param' => 'value'));
As Twig Extension

It brings the daily forecasts as html formatted in bootstrap table., (*10)

{{ pianosolo_get_forecast('Istanbul', 5) }}

This brings 5 days weather information of Istanbul ( Date, City, Temperature, Description ), (*11)

{{ pianosolo_get_weather('Istanbul') }}

This brings 1 day of weather reasults of Istanbul ( Date, City, Temperature, Description ), (*12)

As Weather Service

1-) Get weather response as stdclass object, (*13)

``` php $weatherService = $this->get('pianosolo.weather'); $weather = $weatherService->getWeather('Istanbul');, (*14)


2-) Get weather as weather object ``` php $weatherService = $this->get('pianosolo.weather'); $weathersArray = $weatherService->getWeatherObject('Istanbul'); $weatherObject = $weathersArray[0]; $city = $WeatherObject->getCity(); $date = $WeatherObject->getWdate(); $temperature = $WeatherObject->getTemperature(); $description = $WeatherObject->getDescription();

3-) Get forecast response as stdclass object, (*15)

``` php $weatherService = $this->get('pianosolo.weather'); $weather = $weatherService->getForecast('Istanbul', 2); // 2 days weather results of the city, (*16)


4-) Get forecast as weather object array ``` php $weatherService = $this->get('pianosolo.weather'); $weathersArray = $weatherService->getForecastObject('Istanbul',2); foreach($weathersArray as $weatherObject){ $city = $WeatherObject->getCity(); $date = $WeatherObject->getWdate(); $temperature = $WeatherObject->getTemperature(); $description = $WeatherObject->getDescription(); // Your Logic... }

The Versions

03/08 2017

3.x-dev

3.9999999.9999999.9999999-dev

Weather Bundle of Symfony

  Sources   Download

MIT

The Requires

 

The Development Requires

by Ahmet Akbana

31/07 2017

dev-master

9999999-dev

Weather Bundle of Symfony

  Sources   Download

MIT

The Requires

 

The Development Requires

by Ahmet Akbana

31/07 2017

v2.1.0

2.1.0.0

Weather Bundle of Symfony

  Sources   Download

MIT

The Requires

 

The Development Requires

by Ahmet Akbana

02/02 2017

v2.0.0

2.0.0.0

Weather Bundle of Symfony

  Sources   Download

MIT

The Requires

 

The Development Requires

by Ahmet Akbana

06/05 2016

v1.2.0

1.2.0.0

Weather Bundle of Symfony

  Sources   Download

MIT

The Requires

 

The Development Requires

by Ahmet Akbana

04/05 2016

v1.1.0

1.1.0.0

Weather Bundle of Symfony

  Sources   Download

MIT

The Requires

 

The Development Requires

by Ahmet Akbana

12/10 2015

v1.0.0

1.0.0.0

Weather Bundle of Symfony

  Sources   Download

MIT

The Requires

 

The Development Requires

by Ahmet Akbana