PHPackages                             dnsimmons/openweather - 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. [API Development](/categories/api)
4. /
5. dnsimmons/openweather

AbandonedLibrary[API Development](/categories/api)

dnsimmons/openweather
=====================

OpenWeather is a Laravel package simplifying working with the free Open Weather Map APIs.

1.0.7(4y ago)2226.3k—1.9%9LGPL-3.0PHP

Since Feb 24Pushed 2y ago1 watchersCompare

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

READMEChangelog (7)DependenciesVersions (10)Used By (0)

OpenWeather
===========

[](#openweather)

[![Latest Stable Version](https://camo.githubusercontent.com/94753304bb8a0b1123fb12c5c53d9876a8c0ab176591cb278131bad2cbeb05c3/68747470733a2f2f706f7365722e707567782e6f72672f646e73696d6d6f6e732f6f70656e776561746865722f762f737461626c65)](https://packagist.org/packages/dnsimmons/openweather)[![Latest Unstable Version](https://camo.githubusercontent.com/4c9d0022d9947fbe5c5097e268973e985b9fc870fec3145037b413553990177e/68747470733a2f2f706f7365722e707567782e6f72672f646e73696d6d6f6e732f6f70656e776561746865722f762f756e737461626c65)](https://packagist.org/packages/dnsimmons/openweather)[![Total Downloads](https://camo.githubusercontent.com/7649e876aa88aa2af9f98bd8d8ebbf80fb9ad847ece17b693be9555c9e85f19d/68747470733a2f2f706f7365722e707567782e6f72672f646e73696d6d6f6e732f6f70656e776561746865722f646f776e6c6f616473)](https://packagist.org/packages/dnsimmons/openweather)[![License](https://camo.githubusercontent.com/dcaa671a0f6f05e1f7f8ca19b0bd8b98ba4fbeb8f2be857053331a5021af0160/68747470733a2f2f706f7365722e707567782e6f72672f646e73696d6d6f6e732f6f70656e776561746865722f6c6963656e7365)](https://packagist.org/packages/dnsimmons/openweather)

About
-----

[](#about)

OpenWeather is a [Laravel](https://laravel.com) package simplifying working with the free [Open Weather Map](https://openweathermap.org) APIs.

OpenWeather takes care of making requests to various free Open Weather Map APIs and returns well-structured easy to use weather data including conditions, temperatures, humidity, pressure, wind, location, and timestamp data.

Take a look at the Example Usage section output below for a typical structured response.

### Supported APIs

[](#supported-apis)

The package supports the following free Open Weather Map APIs:

- [Current Weather](https://openweathermap.org/current)
- [4 Day 3 Hour Forecast](https://openweathermap.org/api/hourly-forecast)
- [Onecall Forecast](https://openweathermap.org/api/one-call-api)
- [5 Day Historical](https://openweathermap.org/api/one-call-api#history)

### Free API Limitations

[](#free-api-limitations)

- 60 calls/minute up to 1,000,000 calls/month
- 1000 calls/day when using Onecall requests

### Requirements

[](#requirements)

- A valid Open Weather Maps API Key (AppID).

Install
-------

[](#install)

Use [composer](http://getcomposer.org) to install the package

```
$ composer require dnsimmons/openweather

```

For Laravel &gt;= 5.5 the package is auto-discovered.

For older Laravel versions prior to 5.5 add the service provider to your `config/app.php` along with an alias:

```
'providers' => [
	...
    Dnsimmons\OpenWeather\OpenWeatherServiceProvider::class,
];

'aliases' => [
	...
    'OpenWeather' => Dnsimmons\OpenWeather\OpenWeather::class,
];

```

Publish the required package configuration file using the artisan command:

```
$ php artisan vendor:publish

```

Edit the `.env` file in your Laravel instance add the following environment variables and add your OpenWeather API key:

```
OPENWEATHER_API_KEY="your-api-key"
OPENWEATHER_API_LANG="en"
OPENWEATHER_API_DATE_FORMAT="m/d/Y"
OPENWEATHER_API_TIME_FORMAT="h:i A"
OPENWEATHER_API_DAY_FORMAT="l"

```

Example Usage
-------------

[](#example-usage)

In the example below we fetch the current weather by postal code.

```
$weather = new OpenWeather();
$current = $weather->getCurrentWeatherByPostal('02111');
print_r($current);

```

**Output**

```
Array
(
    [formats] => Array
        (
            [lang] => en
            [date] => m/d/Y
            [day] => l
            [time] => h:i A
            [units] => imperial
        )

    [datetime] => Array
        (
            [timestamp] => 1593387767
            [timestamp_sunrise] => 1593335394
            [timestamp_sunset] => 1593390304
            [formatted_date] => 06/28/2020
            [formatted_day] => Sunday
            [formatted_time] => 11:42 PM
            [formatted_sunrise] => 09:09 AM
            [formatted_sunset] => 12:25 AM
        )

    [location] => Array
        (
            [id] => 4930956
            [name] => Boston
            [country] => US
            [latitude] => 42.36
            [longitude] => -71.06
        )

    [condition] => Array
        (
            [id]   => 801
            [name] => Rain
            [desc] => light rain
            [icon] => https://openweathermap.org/img/w/10d.png
        )

    [wind] => Array
        (
            [speed] => 11.5
            [deg] => 113
            [direction] => SE
        )

    [forecast] => Array
        (
            [temp] => 67
            [temp_min] => 64
            [temp_max] => 68
            [pressure] => 1007
            [humidity] => 88
        )

)

```

Methods
-------

[](#methods)

All methods return an array on success and FALSE on failure.

### Current Weather Methods

[](#current-weather-methods)

**getCurrentWeatherByCityName**(*string $city*, *string $units*)

**Params**

- City Name (example: Boston)
- Units (imperial (default), metric, or kelvin)

**getCurrentWeatherByCityId**(*int $id*, *string $units*)

**Params**

- City ID
- Units (imperial (default), metric, or kelvin)

**getCurrentWeatherByCoords**(*string $latitude*, *string $longitude*, *string $units*)

**Params**

- Latitude
- Longitude
- Units (imperial (default), metric, or kelvin)

**getCurrentWeatherByPostal**(*string $postal*, *string $units*)

**Params**

- US Postal Code
- Units (imperial (default), metric, or kelvin)

### 4 Day 3 Hour Forecast Methods

[](#4-day-3-hour-forecast-methods)

**getForecastWeatherByCityName**(*string $city*, *string $units*)

**Params**

- City Name (example: Boston)
- Units (imperial (default), metric, or kelvin)

**getForecastWeatherByCityId**(*int $id*, *string $units*)

**Params**

- City ID
- Units (imperial (default), metric, or kelvin)

**getForecastWeatherByCoords**(*string $latitude*, *string $longitude*, *string $units*)

**Params**

- Latitude
- Longitude
- Units (imperial (default), metric, or kelvin)

**getForecastWeatherByPostal**(*string $postal*, *string $units*)

**Params**

- US Postal Code
- Units (imperial (default), metric, or kelvin)

### Onecall Request Methods

[](#onecall-request-methods)

**getOnecallWeatherByCoords**(*string $latitude*, *string $longitude*, *string $units*, *string $exclude*)

**Params**

- Latitude
- Longitude
- Units (imperial (default), metric, or kelvin)
- Exclude (optional comma separated values: current,hourly,daily)

### Onecall Historical Request Methods

[](#onecall-historical-request-methods)

**getHistoricalWeatherByCoords**(*string $latitude*, *string $longitude*, *string $date*, *string $units*)

**Params**

- Latitude
- Longitude
- Date (example: 7/12/2020)
- Units (imperial (default), metric, or kelvin)

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity39

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity66

Established project with proven stability

 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

Every ~148 days

Recently: every ~40 days

Total

8

Last Release

1604d ago

### Community

Maintainers

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

---

Top Contributors

[![dnsimmons](https://avatars.githubusercontent.com/u/11092875?v=4)](https://github.com/dnsimmons "dnsimmons (36 commits)")

---

Tags

laravelopenweatherphpweatherweather-api

### Embed Badge

![Health badge](/badges/dnsimmons-openweather/health.svg)

```
[![Health](https://phpackages.com/badges/dnsimmons-openweather/health.svg)](https://phpackages.com/packages/dnsimmons-openweather)
```

###  Alternatives

[stripe/stripe-php

Stripe PHP Library

4.0k143.3M480](/packages/stripe-stripe-php)[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M272](/packages/twilio-sdk)[facebook/php-business-sdk

PHP SDK for Facebook Business

90821.9M34](/packages/facebook-php-business-sdk)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

74513.7M114](/packages/meilisearch-meilisearch-php)[google/gax

Google API Core for PHP

265103.1M454](/packages/google-gax)[google/common-protos

Google API Common Protos for PHP

173103.7M50](/packages/google-common-protos)

PHPackages © 2026

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