PHPackages                             dwr/open-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. dwr/open-weather

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

dwr/open-weather
================

Simply web widget showing weather in defined location based on Open Weather API

1.0.0(9y ago)034MITPHPPHP ~5.6|~7.0

Since Feb 14Pushed 9y ago1 watchersCompare

[ Source](https://github.com/dariuszwrzesien/DwrOpenWeather)[ Packagist](https://packagist.org/packages/dwr/open-weather)[ Docs](https://github.com//dariuszwrzesien//DwrOpenWeather)[ RSS](/packages/dwr-open-weather/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (4)Versions (3)Used By (0)

[![Latest Stable Version](https://camo.githubusercontent.com/af9bc86cfea64eff8d6b942b015ec5d8e6e3417d659bcb8c4b504de77459fc54/68747470733a2f2f706f7365722e707567782e6f72672f6477722f6f70656e2d776561746865722f762f737461626c65)](https://packagist.org/packages/dwr/open-weather)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Build Status](https://camo.githubusercontent.com/c70e9cfb814f800a7a44f85635d058946d00e1aa622a6111a099fe59b51b83ba/68747470733a2f2f7472617669732d63692e6f72672f6461726975737a77727a657369656e2f4477724f70656e576561746865722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/dariuszwrzesien/DwrOpenWeather)[![Coverage Status](https://camo.githubusercontent.com/6fdf7bf0613382fc581dbd55053f109132cbda5bde7967150d29443f18cb286d/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f6461726975737a77727a657369656e2f4477724f70656e576561746865722f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/dariuszwrzesien/DwrOpenWeather?branch=master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/260ce7ff75dcdcc5421fb44a56d5a2fc0eaa03159b76790b9ee21731b3ccc57b/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6461726975737a77727a657369656e2f4477724f70656e576561746865722f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/dariuszwrzesien/DwrOpenWeather/?branch=master)[![Total Downloads](https://camo.githubusercontent.com/27331fe389d5baa1852fffb71e286110167341d9a81d1ece38f0080ff0e50de3/68747470733a2f2f706f7365722e707567782e6f72672f6477722f6f70656e2d776561746865722f646f776e6c6f616473)](https://packagist.org/packages/dwr/open-weather)

DwrOpenWeather
==============

[](#dwropenweather)

DwrOpenWeather is a simply wrapper for [Open Weather API](https://openweathermap.org/).
In order to start please generate your personal ApiKey first.
You can do it [here](http://openweathermap.org/appid).

Installation and usage
----------------------

[](#installation-and-usage)

When you have ApiKey, installation and usage is very easy.

### Step 1: Download DwrOpenWeather using composer

[](#step-1-download-dwropenweather-using-composer)

Add DwrOpenWeather in your composer.json:

```
    {
        "require": {
            "dwr/open-weather": "1.0.0"
        }
    }
```

or download it by running the command:

```
    $ php composer.phar require dwr/open-weather
```

### Step 2: Use it in your application

[](#step-2-use-it-in-your-application)

#### GET Weather

[](#get-weather)

```
    // errors reporting
    ini_set('display_errors', 1);
    ini_set('display_startup_errors', 1);
    error_reporting(E_ALL);

    require __DIR__ . '/vendor/autoload.php';

    use Dwr\OpenWeather\Configuration;
    use Dwr\OpenWeather\OpenWeather;

    $apiKey = YOURS-API-KEY; //consider keeping api key in environment variable: getenv('OPEN_WEATHER_API_KEY');
    $openWeatherConfig = new Configuration($apiKey);

    $openWeather = new OpenWeather('Weather', $openWeatherConfig);
    $weather = $openWeather->getByCityName('London');

    var_dump($weather);
```

You can get weather from OpenWeather API by using:

- getByCityName('London')
- getByCityId('2643743')
    List of city ID city.list.json.gz can be downloaded [here](http://bulk.openweathermap.org/sample/)
- getByGeographicCoordinates(-0.12574, 51.50853)

#### GET Forecast

[](#get-forecast)

```
    // errors reporting
    ini_set('display_errors', 1);
    ini_set('display_startup_errors', 1);
    error_reporting(E_ALL);

    require __DIR__ . '/vendor/autoload.php';

    use Dwr\OpenWeather\Configuration;
    use Dwr\OpenWeather\OpenWeather;

    $apiKey = YOURS-API-KEY;

    //Consider keeping api key in environment variable.
    //$apiKey = getenv('OPEN_WEATHER_API_KEY');

    $openWeatherConfig = new Configuration($apiKey);

    $openWeather = new OpenWeather('Forecast', $openWeatherConfig);
    $forecast = $openWeather->getByCityName('London');

    var_dump($forecast);
```

You can get forecast from OpenWeather API by using:

- getByCityName('London')
- getByCityId('2643743')
    List of city ID city.list.json.gz can be downloaded [here](http://bulk.openweathermap.org/sample/)
- getByGeographicCoordinates(-0.12574, 51.50853)

Configuration (Optional)
------------------------

[](#configuration-optional)

You may configure library on your own if you like. There are several variables which you can set by yourself:

- baseUri,
- version,
- timeout,
- httpClient
- apiKey;

```
    require __DIR__ . '/../vendor/autoload.php';

    use Dwr\OpenWeather\Configuration;
    use Dwr\OpenWeather\OpenWeather;

    $apiKey = YOURS-API-KEY;

    //Consider keeping api key in environment variable.
    //$apiKey = getenv('OPEN_WEATHER_API_KEY');

    $openWeatherConfig = new Configuration($apiKey);

    //CONFIGURATION DwrOpenWeather
    $openWeatherConfig->setBaseUri(NEW-BASE-URI);
    $openWeatherConfig->setVersion(NEW-API-VERSION);
    $openWeatherConfig->setTimeout(NEW-TIMEOUT);
    $openWeatherConfig->setHttpClient(NEW-HTTP-CLIENT); //Has to implement GuzzleHttp\ClientInterface
    $openWeatherConfig->setApiKey(NEW-API-URI);

    $openWeather = new OpenWeather('Weather', $openWeatherConfig);
```

Examples
--------

[](#examples)

Take a moment and check examples directory in DwrOpenWeather. Maybe you will find there a solution which you like.

### weather-basic-small

[](#weather-basic-small)

[![weather-basic-small](examples/img/weather-basic-small.jpg)](examples/img/weather-basic-small.jpg)

### weather-basic-medium

[](#weather-basic-medium)

[![weather-basic-medium](examples/img/weather-basic-medium.jpg)](examples/img/weather-basic-medium.jpg)

### weather-basic-large

[](#weather-basic-large)

[![weather-basic-large](examples/img/weather-basic-large.jpg)](examples/img/weather-basic-large.jpg)

### forecast-chart

[](#forecast-chart)

[![forecast-chart](examples/img/forecast-chart.jpg)](examples/img/forecast-chart.jpg)

### forecast-basic

[](#forecast-basic)

[![forecast-basic](examples/img/forecast-basic.jpg)](examples/img/forecast-basic.jpg)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

26

—

LowBetter than 41% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 52.5% 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 ~0 days

Total

2

Last Release

3422d ago

### Community

Maintainers

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

---

Top Contributors

[![dariuszwrzesien](https://avatars.githubusercontent.com/u/2975063?v=4)](https://github.com/dariuszwrzesien "dariuszwrzesien (31 commits)")[![dwrzesien](https://avatars.githubusercontent.com/u/36001714?v=4)](https://github.com/dwrzesien "dwrzesien (28 commits)")

---

Tags

weatheropen-weatherweather rest api

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/dwr-open-weather/health.svg)

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

###  Alternatives

[neuron-core/neuron-ai

The PHP Agentic Framework.

2.0k496.1k34](/packages/neuron-core-neuron-ai)[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3661.2M46](/packages/tencentcloud-tencentcloud-sdk-php)[civicrm/civicrm-core

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

751284.3k37](/packages/civicrm-civicrm-core)[roundcube/roundcubemail

The Roundcube Webmail suite

7.0k1.4k3](/packages/roundcube-roundcubemail)[spatie/laravel-export

Create a static site bundle from a Laravel app

672139.5k6](/packages/spatie-laravel-export)[nfse-nacional/nfse-php

This is my package nfse

1533.1k](/packages/nfse-nacional-nfse-php)

PHPackages © 2026

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