🌤️ A wrapper around Open Weather Map API (Current weather)
You can install the package via composer:
composer require gnahotelsolutions/laravel-weather
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'));
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'));
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'));
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'));
composer test
Please see CHANGELOG for more information what has changed recently.
Please see CONTRIBUTING for details.
If you discover any security related issues, please email dllop@gnahs.com instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.