sablesoft / api-openweather
A php service for Open Weather API
Installs: 11
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 1
Open Issues: 0
pkg:composer/sablesoft/api-openweather
Requires
- php: >=7.0
- guzzlehttp/guzzle: ~5.0
This package is auto-updated.
Last update: 2025-09-23 10:49:27 UTC
README
PHP Service for the Open Weather API
Installation
Using composer:
"require": {
"sablesoft/api-openweather": "*"
}
Via CLI:
composer require sablesoft/api-openweather
Configuration
Required configurations:
- The appId must be set in your application. (Please see here to get one)
Custom configurations:
- the Base URL and Default Guzzle Options. (Please see here for possible options)
Usage
See below for sample initialization code:
<?php
include_once 'vendor/autoload.php';
use SableSoft\OpenWeather\Service;
$appId = 'your_appid_here';
$options = [
'endpount' => 'http://api.openweathermap.org' // already set as default
'timeout' => 3, // default
'connect_timeout' => 3 // default
];
$service = Service::getInstance($appId, $baseUrl, $options);
// get weather forecast by city:
$response = $service->getByCity('Minsk');
if ($response->isValid()) {
print_r($response->getData());
}
// get weather forecast by coordinates:
$response = $service->get(53.9006, 27.5590);
if ($response->isValid()) {
print_r($response->getData());
}
?>