PHPackages                             mhaggag/laravel-weather - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. mhaggag/laravel-weather

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

mhaggag/laravel-weather
=======================

A Laravel package for fetching weather data via Open-Meteo API.

v1.0.0(3mo ago)01MITPHPPHP &gt;=8.2

Since Jan 14Pushed 3mo agoCompare

[ Source](https://github.com/mahmoudhaggag641/laravel-weather)[ Packagist](https://packagist.org/packages/mhaggag/laravel-weather)[ RSS](/packages/mhaggag-laravel-weather/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (7)Versions (2)Used By (0)

Laravel Weather
===============

[](#laravel-weather)

A robust Laravel package to fetch, cache, and format weather data using the [Open-Meteo API](https://open-meteo.com/). It supports multi-language suggestions (English &amp; Arabic), unit conversion, and flexible configuration.

🌟 Features
----------

[](#-features)

- **Current, Hourly &amp; 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
--------------

[](#-installation)

### 1. Install via Composer

[](#1-install-via-composer)

```
composer require mhaggag/laravel-weather
```

### 2. Publish Configuration &amp; Translations

[](#2-publish-configuration--translations)

Publish the configuration file and translation resources to your application:

```
php artisan vendor:publish --provider="MHaggag\LaravelWeather\WeatherServiceProvider"

# Or publish specific resources:
php artisan vendor:publish --tag="weather-config"

php artisan vendor:publish --tag="weather-translations"

php artisan vendor:publish --tag="weather-views"
```

This will publish:

- `config/weather.php`
- `lang/vendor/weather` (for customizing translations)
- `resources/views/vendor/weather` (for customizing the demo view)

### 3. Environment Configuration

[](#3-environment-configuration)

Add the following to your `.env` file to customize defaults:

```
OPEN_METEO_URL=https://api.open-meteo.com/v1
WEATHER_CACHE_TTL=300
WEATHER_UNITS=metric
WEATHER_TIMEZONE=auto
WEATHER_HTTP_TIMEOUT=8
WEATHER_ENABLE_DEMO=false
```

🚀 Usage
-------

[](#-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

[](#get-current-weather)

Returns a simplified array with current weather conditions, formatted according to your locale and units.

```
use MHaggag\LaravelWeather\Facades\Weather;

public function index()
{
    // Get current weather for Cairo (Lat: 30.0444, Lon: 31.2357)
    $current = Weather::current(30.0444, 31.2357);

    // With options (e.g., Arabic output)
    $currentAr = Weather::current(30.0444, 31.2357, ['locale' => 'ar']);

    return $current;
}
```

**Output Example:**

```
{
    "temperature": "25.0 °C",
    "windspeed": "15.0 km/h",
    "condition": "Clear",
    "icon": "sun",
    "time": "2023-10-05T12:00"
}
```

### Get Raw Data

[](#get-raw-data)

Fetch the raw response from Open-Meteo if you need to process it manually.

```
$rawData = Weather::get(30.0444, 31.2357, [
    'hourly' => ['temperature_2m', 'rain'],
    'daily' => ['temperature_2m_max']
]);
```

And format data according to your needs.

```
$data = Weather::format($rawData, [
    'units' => 'imperial',
    'locale' => 'en'
]);
```

### Or Do both in One Step

[](#or-do-both-in-one-step)

Get Formatted Data (Current + Hourly + Daily):

```
$data = Weather::getAsFormatted(30.0444, 31.2357, [
    'units' => 'imperial',
    'locale' => 'en'
]);
```

### Weather Suggestions

[](#weather-suggestions)

Get a helpful message based on the weather data.

```
$suggestion = Weather::getSuggestion($rawData, ['locale' => 'en']);
// Output: "Clear skies and high temperature — stay hydrated if heading out."
```

⚙️ Configuration
----------------

[](#️-configuration)

Check `config/weather.php` for advanced settings.

### Custom Suggestions

[](#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.

```
'suggestions' => [
    [
        'condition' => 'Rain',
        'message' => 'Don\'t forget your umbrella!',
    ],
    [
        'min_temp' => 35,
        'message' => 'It\'s scorching hot outside!',
    ],
],
```

Sample View Screenshots
-----------------------

[](#sample-view-screenshots)

You can enable the demo view in `config/weather.php` to see the sample view.

EnglishArabic[![Sample view as English](resources/images/mhaggag-laravel-weather-en.png)](resources/images/mhaggag-laravel-weather-en.png)[![Sample view as Arabic](resources/images/mhaggag-laravel-weather-ar.png)](resources/images/mhaggag-laravel-weather-ar.png)🧪 Testing
---------

[](#-testing)

Run the package tests:

```
composer test
```

📄 License
---------

[](#-license)

The MIT License (MIT).

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance78

Regular maintenance activity

Popularity1

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

118d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/d8878cb195a9c7ab67015ad3df7ecadefad07ec8ccb33992abd038d296298fd0?d=identicon)[haggag](/maintainers/haggag)

---

Top Contributors

[![mahmoudhaggag641](https://avatars.githubusercontent.com/u/17066788?v=4)](https://github.com/mahmoudhaggag641 "mahmoudhaggag641 (2 commits)")

---

Tags

laravellaravel-weatheropen-meteoopen-meteo-apiphpweather

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/mhaggag-laravel-weather/health.svg)

```
[![Health](https://phpackages.com/badges/mhaggag-laravel-weather/health.svg)](https://phpackages.com/packages/mhaggag-laravel-weather)
```

###  Alternatives

[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9682.1M97](/packages/roots-acorn)[spatie/laravel-pjax

A pjax middleware for Laravel 5

513371.8k11](/packages/spatie-laravel-pjax)[beyondcode/laravel-favicon

Create dynamic favicons based on your environment settings.

37345.5k](/packages/beyondcode-laravel-favicon)[interaction-design-foundation/laravel-geoip

Support for multiple Geographical Location services.

17221.0k3](/packages/interaction-design-foundation-laravel-geoip)[bjuppa/laravel-blog

Add blog functionality to your Laravel project

483.3k2](/packages/bjuppa-laravel-blog)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
