PHP code example of pianosolo / weather-bundle

1. Go to this page and download the library: Download pianosolo/weather-bundle library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

pianosolo / weather-bundle example snippets



// app/AppKernel.php
	
public function registerBundles()
{
    $bundles = array(
        // ...
        new PianoSolo\WeatherBundle\PianoSoloWeatherBundle(),
    );
}
bash
sudo apt-get install php-apc
 php
$weatherService = $this->get('pianosolo.weather');
$weather = $weatherService->getData('forecast', array('id' => 800, 'lat' => 52.52, 'lon' => 13.41));
 php
$weatherService = $this->get('pianosolo.weather');
$weather = $weatherService->getCityData('weather', 'Berlin', array('param' => 'value'));
twig
{{ pianosolo_get_forecast('Istanbul', 5) }}
 php
$weatherService = $this->get('pianosolo.weather');
$weather = $weatherService->getWeather('Istanbul');
 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();
 php
$weatherService = $this->get('pianosolo.weather');
$weather = $weatherService->getForecast('Istanbul', 2); // 2 days weather results of the city
 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...
}