gnahotelsolutions/laravel-weather

๐ŸŒค๏ธ A wrapper around Open Weather Map to get the current weather on a location.
5,327 38
Install
composer require gnahotelsolutions/laravel-weather
Latest Version:v1.3.0
PHP:^7.1|^8.0
License:MIT
Last Updated:Sep 22, 2021
Links: GitHub  ·  Packagist
Maintainer: lloople

Laravel Open Weather Map Wrapper

Latest Version on Packagist Build status Quality Score Total Downloads

๐ŸŒค๏ธ A wrapper around Open Weather Map API (Current weather)

Installation

You can install the package via composer:

composer require gnahotelsolutions/laravel-weather

Usage

Fill the WEATHER_API_KEY environment variable with your own API key to query the server.


use GNAHotelSolutions\Weather\Weather;

$weather = new Weather();

// Checking weather by city name
$currentWeatherInGirona = json_decode($weather->get('girona,es'));

// You can use the city id, this will get you unambiguous results
$currentWeatherInGirona = json_decode($weather->find('3121456'));

Units

By default the package uses metric for Celsius temperature results, this can be modified using the configuration file or on the fly:

$weather = new Weather();

$currentWeatherInGirona = json_decode($weather->inUnits('imperial')->get('girona,es'));

Language

By default the package uses es for the description translation, this can be modified using the configuration file or on the fly:

$weather = new Weather();

$currentWeatherInGirona = json_decode($weather->inLanguage('en')->get('girona'));

Guzzle Client Instance

If you need to use another instance of Guzzle, to modify headers for example:

$weather = new Weather();

$guzzle = $this->getSpecialGuzzleClient();

$currentWeatherInGirona = json_decode($weather->using($guzzle)->get('girona'));

Testing

composer test

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email dllop@gnahs.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

Related Packages

rakibdevs/openweather-laravel-api

Laravel package to connect https://openweathermap.org/ to get customized weather...

57,329 75
ekstremedia/laravel-netatmo-weather

A Laravel package for integrating Netatmo Weather Station API with your Laravel...

1,439 1
phantom/weather

A simple open weather api client

58
cyvelnet/laravel5-fractal

A simple fractal service provider and transformer generator with model attribute...

190,086 79

Version History

Version Released PHP Laravel License
v1.3.0 ^7.1|^8.0 5.8.*|6.*|7.*|8.* MIT
v1.2.0 ^7.1|^7.3 5.8.*|6.*|7.*|8.* MIT
v1.1.0 ^7.1 5.8.*|6.*|7.* MIT
v1.0.0 ^7.1 5.8.*|6.* MIT