Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gnahotelsolutions/laravel-weather
🌤️ A wrapper around Open Weather Map API (Current weather)
https://github.com/gnahotelsolutions/laravel-weather
hacktoberfest laravel laravel-package laravel-weather package php weather
Last synced: about 24 hours ago
JSON representation
🌤️ A wrapper around Open Weather Map API (Current weather)
- Host: GitHub
- URL: https://github.com/gnahotelsolutions/laravel-weather
- Owner: gnahotelsolutions
- License: mit
- Created: 2019-12-02T16:20:41.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2021-09-22T10:23:46.000Z (about 3 years ago)
- Last Synced: 2024-11-14T13:46:47.587Z (6 days ago)
- Topics: hacktoberfest, laravel, laravel-package, laravel-weather, package, php, weather
- Language: PHP
- Homepage:
- Size: 43 KB
- Stars: 38
- Watchers: 5
- Forks: 6
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Laravel Open Weather Map Wrapper
[![Latest Version on Packagist](https://img.shields.io/packagist/v/gnahotelsolutions/laravel-weather.svg?style=flat-square)](https://packagist.org/packages/gnahotelsolutions/laravel-weather)
![Build status](https://github.com/gnahotelsolutions/laravel-weather/actions/workflows/laravel.yml/badge.svg)
[![Quality Score](https://img.shields.io/scrutinizer/g/gnahotelsolutions/laravel-weather.svg?style=flat-square)](https://scrutinizer-ci.com/g/gnahotelsolutions/laravel-weather)
[![Total Downloads](https://img.shields.io/packagist/dt/gnahotelsolutions/laravel-weather.svg?style=flat-square)](https://packagist.org/packages/gnahotelsolutions/laravel-weather)🌤️ A wrapper around Open Weather Map API (Current weather)
## Installation
You can install the package via composer:
```bash
composer require gnahotelsolutions/laravel-weather
```## Usage
Fill the `WEATHER_API_KEY` environment variable with your own API key to query the server.
```php
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:```php
$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:```php
$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:```php
$weather = new Weather();$guzzle = $this->getSpecialGuzzleClient();
$currentWeatherInGirona = json_decode($weather->using($guzzle)->get('girona'));
```### Testing
```bash
composer test
```### Changelog
Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.
## Contributing
Please see [CONTRIBUTING](CONTRIBUTING.md) for details.
### Security
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
## Credits
- [David Llop](https://github.com/lloople)
- [All Contributors](../../contributors)## License
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.