php-weather/openweathermap

OpenWeatherMap provider

0.2.1 2024-02-27 19:35 UTC

This package is auto-updated.

Last update: 2024-04-27 20:00:36 UTC


README

Packagist Version
PHP Weather Common Version PHP Weather HTTP Provider Version
GitHub Release Date GitHub commits since tagged version GitHub last commit
GitHub Workflow Status GitHub Packagist PHP Version Support

This is the OpenWeatherMap provider from PHP Weather.

Installation

Via Composer

composer require php-weather/openweathermap

Usage

$openWeatherMapKey = 'key';

$httpClient = new \Http\Adapter\Guzzle7\Client();
$openweathermap = new \PhpWeather\Provider\OpenWeatherMap\OpenWeatherMap($httpClient, $openWeatherMapKey);

$latitude = 47.873;
$longitude = 8.004;

$currentWeatherQuery = \PhpWeather\Common\WeatherQuery::create($latitude, $longitude);
$currentWeather = $openweathermap->getCurrentWeather($currentWeatherQuery);