modulor / weather
get weather from openweathermap api
dev-master
2016-12-13 05:47 UTC
Requires
- php: >=5.5.0
This package is not auto-updated.
Last update: 2025-07-14 18:08:18 UTC
README
Basic API usage from openweathermap.org
Installation
via Composer:
Create or add the following to composer.json in your project root:
{ "repositories": [ { "type": "vcs", "url": "https://github.com/modulor/weather" } ], "require": { "modulor/weather": "dev-master" } }
run composer install
Example
Get weather by city name
require_once("path/to/vendor/autoload.php"); WeatherAPI\Configs::setApiKey('your_api_key'); $searchWeather = new WeatherAPI\Current\Search(); $searchWeather->setQueryParams(array( 'q' => 'london' )); print_r($searchWeather->execute());
Get weather by geographic coordinates
require_once("path/to/vendor/autoload.php"); WeatherAPI\Configs::setApiKey('your_api_key'); $searchWeather = new WeatherAPI\Current\Search(); $searchWeather->setQueryParams(array( 'lat' => '-22.0622478', 'lon' => '-44.0444834' )); print_r($searchWeather->execute());