PHPackages                             jamesmorrison/metar - 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. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. jamesmorrison/metar

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

jamesmorrison/metar
===================

A PHP 8.4 METAR weather report parser. Parses raw METAR strings into structured, readonly value objects with full remark support and human-readable labels.

v0.2.0(2mo ago)02MITPHPPHP ^8.4CI passing

Since May 15Pushed 2mo agoCompare

[ Source](https://github.com/jamesmorrison/metar)[ Packagist](https://packagist.org/packages/jamesmorrison/metar)[ Docs](https://github.com/jamesmorrison/metar)[ RSS](/packages/jamesmorrison-metar/feed)WikiDiscussions trunk Synced 3w ago

READMEChangelog (2)Dependencies (8)Versions (5)Used By (0)

Metar
=====

[](#metar)

A PHP 8.4 METAR weather report parser. Parses raw METAR strings into structured, readonly value objects with full remark support and human-readable labels.

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

[](#installation)

```
composer require jamesmorrison/metar
```

Requires PHP 8.4 or higher.

Usage
-----

[](#usage)

```
use JamesMorrison\Metar\Parser;

$metar = new Parser('METAR EGLL 141250Z 24015G25KT 9999 FEW040CB 12/08 Q1015 NOSIG');
```

### Accessing Components

[](#accessing-components)

Every component is a readonly value object with typed properties and a `label()` method:

```
$metar->station->icao;               // 'EGLL'
$metar->observationTime->day;        // 14
$metar->observationTime->hour;       // 12
$metar->observationTime->minute;     // 50

$metar->wind->direction;             // 240
$metar->wind->speed;                 // 15
$metar->wind->gusts;                 // 25
$metar->wind->unit;                  // WindUnit::Knots
$metar->wind->speedKnots;            // 15.0
$metar->wind->speedMps;              // 7.7

$metar->visibility->distance;        // 9999.0
$metar->visibility->unit;            // VisibilityUnit::Metres

$metar->clouds[0]->amount;           // CloudAmount::Few
$metar->clouds[0]->height;           // 4000
$metar->clouds[0]->type;             // CloudType::Cumulonimbus

$metar->temperature->temperature;    // 12
$metar->temperature->dewpoint;       // 8

$metar->pressure->hectopascals;      // 1015.0
$metar->pressure->inchesOfMercury;   // 29.97
```

### Human-Readable Labels

[](#human-readable-labels)

All components implement `Labelable` and `Stringable`:

```
$metar->wind->label();       // 'Wind from 240 degrees at 15 knots gusting 25 knots'
$metar->pressure->label();   // '1015 hPa / 29.97 inHg'
echo $metar->temperature;    // 'Temperature 12°C (54°F), dewpoint 8°C (46°F)'

// Full METAR summary
echo $metar->label();
```

### JSON Serialization

[](#json-serialization)

The parser implements `JsonSerializable`:

```
json_encode($metar, JSON_PRETTY_PRINT);
```

### CAVOK

[](#cavok)

When CAVOK is reported, visibility/weather/clouds are not parsed:

```
$metar = new Parser('METAR EGLL 141250Z 24015KT CAVOK 12/08 Q1015');
$metar->cavok; // true
```

Parsed Components
-----------------

[](#parsed-components)

PropertyTypeDescription`station``?Station`ICAO station identifier`observationTime``?ObservationTime`Day, hour, and minute (UTC)`modifiers``Modifier[]`AUTO, COR, etc.`wind``?Wind`Direction, speed, gusts, unit (with dual-unit conversions)`windVariation``?WindVariation`Variable wind direction range`visibility``?Visibility`Prevailing visibility (with dual-unit conversions)`directionalVisibility``DirectionalVisibility[]`Sector-specific visibility`runwayVisualRange``RunwayVisualRange[]`RVR per runway`weather``Weather[]`Present weather phenomena`clouds``Cloud[]`Cloud layers`temperature``?Temperature`Temperature and dewpoint (Celsius + Fahrenheit)`pressure``?Pressure`Altimeter setting (hPa + inHg)`windShear``?WindShear`Wind shear warnings`recentWeather``RecentWeather[]`Recent weather phenomena`trends``Trend[]`NOSIG, TEMPO, BECMG trends`remarks``?Remarks`Decoded remark groups`cavok``bool`Ceiling and visibility OKRemarks
-------

[](#remarks)

The parser decodes 25+ remark types including:

- Station type (AO1/AO2)
- Sea-level pressure
- Peak wind and wind shift
- Hourly temperature / temperature extremes
- Pressure tendency and rapid pressure change
- Precipitation (hourly, 3/6-hour, 24-hour)
- Lightning (frequency, type, direction)
- Weather events (beginning/ending times)
- Variable ceiling and visibility
- Significant clouds (CB, TCU, ACC, etc.)
- Virga, obscurations, snow depth/increase
- Sensor status and maintenance indicators

```
$metar = new Parser('METAR KJFK 141250Z 24015KT 10SM FEW040 12/08 A2997 RMK AO2 SLP153 T01170083');

foreach ($metar->remarks->groups as $remark) {
    echo $remark->label() . "\n";
}
```

Testing
-------

[](#testing)

```
composer pest      # Run tests
composer analyse   # PHPStan (max level)
composer pint      # Code style
composer test      # All of the above
```

License
-------

[](#license)

MIT

###  Health Score

36

—

LowBetter than 79% of packages

Maintenance86

Actively maintained with recent releases

Popularity2

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity44

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

Every ~0 days

Total

2

Last Release

70d ago

### Community

Maintainers

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

---

Top Contributors

[![jamesmorrison](https://avatars.githubusercontent.com/u/141750?v=4)](https://github.com/jamesmorrison "jamesmorrison (10 commits)")

---

Tags

parserweatheraviationMETAR

###  Code Quality

TestsPest

Static AnalysisRector

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/jamesmorrison-metar/health.svg)

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

###  Alternatives

[nikic/php-parser

A PHP parser written in PHP

17.5k954.1M2.5k](/packages/nikic-php-parser)[doctrine/lexer

PHP Doctrine Lexer parser library that can be used in Top-Down, Recursive Descent Parsers.

11.2k963.0M160](/packages/doctrine-lexer)[erusev/parsedown

Parser for Markdown.

15.1k156.8M875](/packages/erusev-parsedown)[league/commonmark

Highly-extensible PHP Markdown parser which fully supports the CommonMark spec and GitHub-Flavored Markdown (GFM)

3.0k437.5M1.1k](/packages/league-commonmark)[masterminds/html5

An HTML5 parser and serializer.

1.8k269.7M327](/packages/masterminds-html5)[sabberworm/php-css-parser

Parser for CSS Files written in PHP

1.8k211.0M78](/packages/sabberworm-php-css-parser)

PHPackages © 2026

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