🌤️ A wrapper around Open Weather Map API (Current weather)
You can install the package via composer:
source-shell
composer require gnahotelsolutions/laravel-weather
text-html-php
$weather = new Weather();
// Checking weather by city name
$currentWeatherInGirona = $weather->get('girona,es');
// You can use the city id, this will get you unambiguous results
$currentWeatherInGirona = $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:
text-html-php
$weather = new Weather();
$currentWeatherInGirona = $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:
text-html-php
$weather = new Weather();
$currentWeatherInGirona = $weather->inLanguage('en')->get('girona');
If you need to use another instance of Guzzle, to modify headers for example:
text-html-php
$weather = new Weather();
$guzzle = $this->getSpecialGuzzleClient();
$currentWeatherInGirona = $weather->using($guzzle)->get('girona');
source-shell
composer test
#Laravel #PHP #WebDev #php #laravel