PHPackages                             ajur-media/ajur.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. ajur-media/ajur.weather

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

ajur-media/ajur.weather
=======================

AJUR Media Steamboat Weather toolkit

2.0.0(12mo ago)0552MITPHPPHP ^8.2

Since Jun 18Pushed 12mo ago1 watchersCompare

[ Source](https://github.com/ajur-media/ajur.weather)[ Packagist](https://packagist.org/packages/ajur-media/ajur.weather)[ RSS](/packages/ajur-media-ajurweather/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (7)Dependencies (3)Versions (8)Used By (0)

AJUR Media Steamboat Weather toolkit
====================================

[](#ajur-media-steamboat-weather-toolkit)

Методы
------

[](#методы)

#### Weather::init()

[](#weatherinit)

```
/**
 * @param null $api_key -- API-ключ для доступа к OpenWeather
 * @param array $options -- 2 опции: units:metric|imperial, lang:ru|en|..
 * @param null $logger -- null или Logger
 * @throws Exception
 */
public static function init($api_key = null, $options = [], $logger = null)

```

Для загрузки погоды с серверов OpenWeatherMap требуется указать API-key. Для загрузки погоды из файла достаточно (но не необходимо) указать Logger.

#### Weather::loadLocalWeather()

[](#weatherloadlocalweather)

```
/**
 * @param int $district_id
 * @param null $source_file
 * @return array
 */
public static function loadLocalWeather($district_id = 0, $source_file = null)

```

Загружает данные о погоде для определенного региона (0 для всех) из JSON-файла. Структура файла:

```
{
    "update_ts": 1592480232,
    "update_time": "2020-06-18 14-37-12",
    "data": {}
}

```

`data` - объект, в котором ключ - идентификатор региона в кодировке OpenWeatherMap, данные по ключу - информация о погоде в регионе.

#### Weather::fetchWeatherGroup()

[](#weatherfetchweathergroup)

```
/**
 * Загружает из OpenWeather погоду для переданного массива регионов
 *
 * @param array $regions_list - либо список регионов (многомерный массив), либо список ключей регионов (array_keys)
 * @return array
 * @throws OpenWeatherMap\Exception
 */
public static function fetchWeatherGroup(array $regions_list):array

```

Аргументом `$regions_list` может служить как список регионов (многомерный массив типа `WeatherConstants::outer_regions`), так и список идентификаторов регионов в формате OpenWeatherMap (в общем случае `array_keys(WeatherConstants::outer_regions)`)

#### Weather::fetchWeatherGroupDebug()

[](#weatherfetchweathergroupdebug)

```
/**
 * @param array $regions_list
 * @return array
 * @throws OpenWeatherMap\Exception
 */
public static function fetchWeatherGroupDebug(array $regions_list): array

```

Отладочный метод. Аргументом может служить только многомерный массив-список регионов.

Константы (WeatherConstants)
----------------------------

[](#константы-weatherconstants)

Идентификаторы регионов представлены в двух пространствах значений.

- Внутренние коды для сайта 47news (&lt;100)
- Коды для OpenWeatherMap

Константы:

- `lo_adjacency_lists` - Список смежности регионов ЛенОбласти. Значения - внутренние идентификаторы регионов на сайте 47news
- `map_intid_to_owmid` - таблица маппинга регионов ЛенОбласти на таблицу регионов OWMID
- `REGION_SPB` - код региона "Санкт-Петербург" в пространстве кодов OWMID
- `REGION_LO` - код региона "Ленинградкая Область" в пространстве кодов OWMID
- `outer_regions` - список всех регионов СПб и Ленобласти в пространстве кодов OWMID
- `icons_conversion` - таблица маппинга - код погоды в имя файла иконки

Как использовать?
=================

[](#как-использовать)

Получаем погоду с сервера OWM:

```
require_once 'vendor/autoload.php';

use AJUR\Toolkit\Weather;

Weather::init('');

$data = Weather::fetchWeatherGroup( array_keys( \AJUR\Toolkit\WeatherConstants::outer_regions ) );

$data = [
    'update_ts'     =>  time(),
    'update_time'   =>  (new \DateTime())->format('Y-m-d H-i-s'),
    'data'          =>  $data
];

file_put_contents('weather.json', json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE  ), LOCK_EX);

```

Загружаем погоду на сайте:

```
use AJUR\Toolkit\Weather;

Weather::init(null, [], AppLogger::scope('log.weather'));
$weather_source = getenv('STORAGE.WEATHER');
$weather = Weather::loadLocalWeather($current_district_id, $weather_source);

```

###  Health Score

39

—

LowBetter than 85% of packages

Maintenance50

Moderate activity, may be stable

Popularity13

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity73

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 ~306 days

Recently: every ~427 days

Total

7

Last Release

364d ago

Major Versions

0.9 → 1.02020-06-18

1.99.1 → 2.0.02025-06-28

PHP version history (3 changes)0.9PHP ^7.2

1.99.1PHP ^7.4 | 8.\*

2.0.0PHP ^8.2

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/2164874?v=4)[Karel Wintersky](/maintainers/KarelWintersky)[@KarelWintersky](https://github.com/KarelWintersky)

---

Top Contributors

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

###  Code Quality

Static AnalysisRector

### Embed Badge

![Health badge](/badges/ajur-media-ajurweather/health.svg)

```
[![Health](https://phpackages.com/badges/ajur-media-ajurweather/health.svg)](https://phpackages.com/packages/ajur-media-ajurweather)
```

###  Alternatives

[symfony/lock

Creates and manages locks, a mechanism to provide exclusive access to a shared resource

514135.1M626](/packages/symfony-lock)[matomo/matomo

Matomo is the leading Free/Libre open analytics platform

21.6k38.2k](/packages/matomo-matomo)[phpro/soap-client

A general purpose SoapClient library

8895.9M52](/packages/phpro-soap-client)[ecotone/ecotone

Enterprise architecture layer for Laravel and Symfony — CQRS, Event Sourcing, Durable Workflows (Sagas, Orchestrators), Projections, and Outbox messaging via PHP attributes.

562565.8k42](/packages/ecotone-ecotone)[civicrm/civicrm-core

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

749284.3k37](/packages/civicrm-civicrm-core)[illuminate/broadcasting

The Illuminate Broadcasting package.

7126.9M203](/packages/illuminate-broadcasting)

PHPackages © 2026

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