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

ActiveLibrary[API Development](/categories/api)

scrnr/weather
=============

OpenWeatherApi application in PHP

v1.0.0(3y ago)11292MITPHPPHP &gt;=8.0

Since Apr 27Pushed 3y ago1 watchersCompare

[ Source](https://github.com/scrnr/OpenWeatherApi-PHP)[ Packagist](https://packagist.org/packages/scrnr/weather)[ Docs](https://github.com/scrnr/OpenWeatherApi-PHP)[ RSS](/packages/scrnr-weather/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)DependenciesVersions (2)Used By (0)

OpenWeatherMap API Application in PHP
=====================================

[](#openweathermap-api-application-in-php)

 [![PHP Version](https://camo.githubusercontent.com/f1317bc6d20f2615bd770ca4d2f6cb99df49bc4245516c9e74ee35375961dab5/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646570656e64656e63792d762f7363726e722f776561746865722f7068703f6c6162656c3d504850266c6f676f3d706870267374796c653d706c617374696326636f6c6f723d6f72616e6765)](https://camo.githubusercontent.com/f1317bc6d20f2615bd770ca4d2f6cb99df49bc4245516c9e74ee35375961dab5/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646570656e64656e63792d762f7363726e722f776561746865722f7068703f6c6162656c3d504850266c6f676f3d706870267374796c653d706c617374696326636f6c6f723d6f72616e6765) [![Packagist Version](https://camo.githubusercontent.com/98deb1bf109b37fb3561854e592c6cee503f7eabb329323bde7c227e3241e844/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7363726e722f776561746865723f6c6162656c3d5061636b6167697374266c6f676f3d7061636b6167697374266c6f676f436f6c6f723d7768697465267374796c653d706c6173746963)](https://camo.githubusercontent.com/98deb1bf109b37fb3561854e592c6cee503f7eabb329323bde7c227e3241e844/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7363726e722f776561746865723f6c6162656c3d5061636b6167697374266c6f676f3d7061636b6167697374266c6f676f436f6c6f723d7768697465267374796c653d706c6173746963) [![LICENSE](https://camo.githubusercontent.com/57224fedcd9b96134e637790c7b514a768cf8f1b19dca92c064e648b0eb21957/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f7363726e722f776561746865723f6c6162656c3d4c4943454e5345267374796c653d706c6173746963)](https://camo.githubusercontent.com/57224fedcd9b96134e637790c7b514a768cf8f1b19dca92c064e648b0eb21957/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f7363726e722f776561746865723f6c6162656c3d4c4943454e5345267374796c653d706c6173746963)

Table Of Contects
-----------------

[](#table-of-contects)

- [Description](#description)
- [Installation](#installation)
- [How to use](#how-to-use)
- [Example](#for-example)
- [Features](#features)
- [Requirements](#requirements)
- [Author](#author)
- [License](#license)

Description
-----------

[](#description)

This repository written in PHP that allows you to check the weather for a particular location using the OpenWeatherMap API 2.5. The app can determine your location by IP address and show the weather information or you can enter the name of any city.

Installation
------------

[](#installation)

You can install the library using [Composer](https://getcomposer.org/). Simply add the following lines to your `composer.json` file and run `composer install`:

```
"require": {
    "scrnr/weather": "*"
}
```

Or you can use this **command**:

```
composer require scrnr/weather
```

How to use
----------

[](#how-to-use)

To use this app, you'll need to obtain an **API key** from the [OpenWeatherMap website](https://openweathermap.org/api) and set it using the `setToken()` function. The `setToken()` function accepts a token in string format.

Once you've set your **API key**, you can retrieve weather data using the `getWeather()` function. This function accepts two parameters: `CITY_NAME` and `UNITS_OF_MEASUREMENT`.

- `CITY_NAME` accepts the name of the city in string format
- `UNITS_OF_MEASUREMENT` accepts either `Units::METRIC` or `Units::IMPERIAL` as constants to specify the units of measurement.

If you do not set these parameters, the function will automatically determine the city based on the *IP address* and use the *metric system* as the *default* units of measurement.

If the `getWeather()` function returns false, you can use the `getErrors()` function to retrieve information about the error. This will allow you to troubleshoot any issues that may have occurred during the process.

Thank you for using my OpenWeatherMap API Application!

For example:
------------

[](#for-example)

```
use Scrnr\Weather\Weather;

Weather::setToken('YOUR_TOKEN');
$forecast = Weather::getWeather('CITY_NAME', 'UNITS');

if ($forecast === false) {
    $errors = Weather::getErrors();
}
```

### Output

[](#output)

```
Array
(
    [today] => Array
        (
            [sunrise] => 05:09
            [sunset] => 20:43
            [date] => 27 April
            [description] => Overcast clouds
            [temp] => 5
            [feelsLike] => 1
            [pressure] => 755 mm Hg
            [humidity] => 90%
            [cityName] => Saint Petersburg
            [visibility] => more than 10 km
            [wind] => Array
                (
                    [speed] => 7 m/s
                    [direction] => East
                )

            [isNight] => false
            [icon] => http://openweathermap.org/img/wn/04d@2x.png
            [tempMin] => 4
        )

    [fourDays] => Array
        (
            [0] => Array
                (
                    [date] => 28 April
                    [icon] => http://openweathermap.org/img/wn/04d@2x.png
                    [max] => 7
                    [min] => 3
                )

            [1] => Array
                (
                    [date] => 29 April
                    [icon] => http://openweathermap.org/img/wn/10d@2x.png
                    [max] => 4
                    [min] => 4
                )

            [2] => Array
                (
                    [date] => 30 April
                    [icon] => http://openweathermap.org/img/wn/10d@2x.png
                    [max] => 7
                    [min] => 4
                )

            [3] => Array
                (
                    [date] => 01 May
                    [icon] => http://openweathermap.org/img/wn/10d@2x.png
                    [max] => 7
                    [min] => 2
                )
        )
)
```

Features
--------

[](#features)

This app offers the following features:

- Ability to check weather for a specific city
- Automatic location detection using IP address
- Display of current weather conditions, temperature, humidity, and wind speed
- Display of a 4-day weather forecast

Requirements
------------

[](#requirements)

This app requires `PHP 8.0` or later and the `cURL` and `json` extensions to be installed on your web server.

Author
------

[](#author)

👤 GitHub: [scrnr](https://github.com/scrnr)

License
-------

[](#license)

This project is licensed under the MIT License. See the [LICENSE](https://github.com/scrnr/OpenWeatherApi-PHP/blob/main/LICENSE) file for details.

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity49

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

1114d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/94587b0e9a69af9b970452e6827ea1ceeede5641ef1c9b56ad75cebb8789c12d?d=identicon)[scrnr](/maintainers/scrnr)

---

Top Contributors

[![scrnr](https://avatars.githubusercontent.com/u/130318174?v=4)](https://github.com/scrnr "scrnr (7 commits)")

---

Tags

open-weather-apiphpweatherweatheropen-weather

### Embed Badge

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

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

###  Alternatives

[cmfcmf/openweathermap-php-api

A PHP API to parse weather data from OpenWeatherMap.org. This wrapper tries to normalise and abstract the data and remove inconsistencies.

3471.3M7](/packages/cmfcmf-openweathermap-php-api)[rakibdevs/openweather-laravel-api

Laravel package to connect https://openweathermap.org/ to get customized weather data for any location on the globe immediately

7648.2k](/packages/rakibdevs-openweather-laravel-api)[vemcogroup/laravel-weather

Weather package for Laravel to use different providers to get weather info

5525.0k](/packages/vemcogroup-laravel-weather)[rugaard/weatherkit

Integrate Apple WeatherKit API into your project

111.4k](/packages/rugaard-weatherkit)

PHPackages © 2026

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