Download the PHP package mhaggag/laravel-weather without Composer
On this page you can find all versions of the php package mhaggag/laravel-weather. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download mhaggag/laravel-weather
More information about mhaggag/laravel-weather
Files in mhaggag/laravel-weather
Package laravel-weather
Short Description A Laravel package for fetching weather data via Open-Meteo API.
License MIT
Informations about the package laravel-weather
Laravel Weather
A robust Laravel package to fetch, cache, and format weather data using the Open-Meteo API. It supports multi-language suggestions (English & Arabic), unit conversion, and flexible configuration.
๐ Features
- Current, Hourly & Daily Weather: Fetch comprehensive weather data.
- Localization: Built-in support for English (
en) and Arabic (ar). - Smart Suggestions: Get human-readable advice based on weather conditions (e.g., "Take an umbrella").
- Caching: Automatic caching of API responses to improve performance.
- Units: Supports Metric (ยฐC, km/h) and Imperial (ยฐF, mph) systems.
- Resilient: Handles API timeouts and retries automatically.
๐ฆ Installation
1. Install via Composer
2. Publish Configuration & Translations
Publish the configuration file and translation resources to your application:
This will publish:
config/weather.phplang/vendor/weather(for customizing translations)resources/views/vendor/weather(for customizing the demo view)
3. Environment Configuration
Add the following to your .env file to customize defaults:
๐ Usage
You can use the Weather facade (the alias is automatically registered) or inject the MHaggag\LaravelWeather\Services\WeatherService into your controllers and classes.
Get Current Weather
Returns a simplified array with current weather conditions, formatted according to your locale and units.
Output Example:
Get Raw Data
Fetch the raw response from Open-Meteo if you need to process it manually.
And format data according to your needs.
Or Do both in One Step
Get Formatted Data (Current + Hourly + Daily):
Weather Suggestions
Get a helpful message based on the weather data.
โ๏ธ Configuration
Check config/weather.php for advanced settings.
Custom Suggestions
You can define custom rules for suggestions in the config file. The service evaluates rules in order and returns the message of the first match.
Sample View Screenshots
You can enable the demo view in config/weather.php to see the sample view.
| English | Arabic |
|---|---|
๐งช Testing
Run the package tests:
๐ License
The MIT License (MIT).
All versions of laravel-weather with dependencies
illuminate/cache Version >=11.0
illuminate/http Version >=11.0
illuminate/log Version >=11.0
illuminate/support Version >=11.0
illuminate/translation Version >=11.0