PHP code example of php-weather / open-meteo
1. Go to this page and download the library: Download php-weather/open-meteo 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/ */
php-weather / open-meteo example snippets
$httpClient = new \Http\Adapter\Guzzle7\Client();
$openMeteo = new \PhpWeather\Provider\OpenMeteo\OpenMeteo($httpClient);
$latitude = 47.873;
$longitude = 8.004;
$currentWeatherQuery = \PhpWeather\Common\WeatherQuery::create($latitude, $longitude);
$currentWeather = $openMeteo->getCurrentWeather($currentWeatherQuery);
shell
composer