PHPackages                             okvpn/grib2-eccodes - 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. okvpn/grib2-eccodes

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

okvpn/grib2-eccodes
===================

Read WMO GRIB2 files with using FFI and libeccodes

1.0.0(2y ago)238MITPHPPHP &gt;=8.1

Since Aug 28Pushed 2y ago1 watchersCompare

[ Source](https://github.com/vtsykun/php-grib2)[ Packagist](https://packagist.org/packages/okvpn/grib2-eccodes)[ RSS](/packages/okvpn-grib2-eccodes/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (2)Used By (0)

PHP GRIB2 eccodes
=================

[](#php-grib2-eccodes)

Simple library to read GRIB2 WMO format with using FFI.

Purpose
-------

[](#purpose)

This library shows an example of how to use adapt libeccodes for using with PHP FFI extension to save developers time.

Install
-------

[](#install)

```
composer require okvpn/grib2-eccodes

```

Install libaec-dev

```
apt install libaec-dev

```

(Optional) Install eccodes lib. See .

But to simplify distribution, the libeccodes is build-in with data `eccodes.tar.gz`. It will be extracted to tmp dir.

Usage
=====

[](#usage)

```
# Get grib index data
# https://www.ftp.ncep.noaa.gov/data/nccf/com/gfs/prod/gfs.//atmos/gfs.tz.pgrb2b.1p00.f.idx

170:9120456:d=2023081906:RH:575 mb:3 hour fcst:
171:9195051:d=2023081906:TCDC:575 mb:3 hour fcst:
172:9235360:d=2023081906:VVEL:575 mb:3 hour fcst:
173:9325082:d=2023081906:DZDT:575 mb:3 hour fcst:
174:9400873:d=2023081906:UGRD:575 mb:3 hour fcst:
175:9480146:d=2023081906:VGRD:575 mb:3 hour fcst:
176:9560543:d=2023081906:ABSV:575 mb:3 hour fcst:
177:9632016:d=2023081906:CLWMR:575 mb:3 hour fcst:

```

Download Grib2 archive

```
$curl = new CurlHttpClient();
// Select 174:9400873:d=2023081906:UGRD:575 mb:3 hour fcst:
// Use http 206 Partial Content feature to downlaod only one param
$res = $curl->request('GET', 'https://www.ftp.ncep.noaa.gov/data/nccf/com/gfs/prod/gfs.//atmos/gfs.tz.pgrb2b.1p00.f003', ['headers' => ['Range' => 'bytes=9400873-9480145']]);

file_put_contents("VGRD.p1", $res->getContent())
```

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

use FFI;
use Okvpn\Grib2\Grib2Reader;
use Okvpn\Grib2\LibEccodes;

LibEccodes::$libPath = "libeccodes.so"; // . use fill path if installed eccodes to custom path

$reader = new Grib2Reader();

$data = $reader->read("VGRD.p1");

print_r($data);

$matrix = $reader->read2D("VGRD.p1", lat1: 48, lat2: 57, lon1: 13, lon2: 36);
foreach ($matrix as $i => &$vals) {
    foreach ($vals as $j => &$val) {
        $val = ($s = strlen($val = round($val))) >= 3 ? $val : $val . str_repeat(' ', 3-$s);
    }
}
```

Output

```
5   6   5   3   3   3   3   5   4   4   5   5   5   7   7   7   4   9   6   6   9   5   7   8
5   7   5   2   0   2   2   1   -0  1   2   2   4   4   5   6   6   7   6   6   5   5   6   6
4   6   5   3   2   2   0   0   1   2   1   1   2   3   2   2   3   1   1   1   2   2   5   4
5   5   5   3   3   2   2   1   3   5   6   5   4   3   3   2   -0  -1  -1  -2  -2  -3  -3  -1
6   6   5   3   3   3   2   4   4   5   4   4   4   4   2   1   0   -0  -0  -2  -1  -1  -3  -4
5   6   6   1   2   2   2   3   4   4   3   2   3   2   2   3   0   0   -0  -2  -1  -1  -2  -3
5   4   1   1   1   0   1   4   3   1   2   1   2   3   4   3   2   0   -1  -0  -2  -2  -2  -3
4   1   1   1   0   1   2   2   2   1   2   2   3   2   3   3   1   0   -0  -1  -2  -3  -4  -3
2   0   1   -1  -0  1   2   1   0   1   1   2   3   3   1   1   0   -0  0   0   -1  -3  -5  -4
-1  -1  -3  -2  -0  -1  -2  -2  -2  -1  0   2   2   2   2   1   0   0   -0  -1  -1  -3  -5  -5

```

License
-------

[](#license)

MIT License.

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity52

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

985d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/72ab45c38dd8963c58e34948277405642f3e498f5ffc7508cea6e51a5dcdd24f?d=identicon)[vtsykun](/maintainers/vtsykun)

---

Top Contributors

[![vtsykun](https://avatars.githubusercontent.com/u/21358010?v=4)](https://github.com/vtsykun "vtsykun (3 commits)")

---

Tags

grib2grib2-phpgrib2eccodesnceppgrb2b

### Embed Badge

![Health badge](/badges/okvpn-grib2-eccodes/health.svg)

```
[![Health](https://phpackages.com/badges/okvpn-grib2-eccodes/health.svg)](https://phpackages.com/packages/okvpn-grib2-eccodes)
```

###  Alternatives

[smart-crowd/simple-sms-drivers

Addition providers for simple SMS laravel package

101.0k](/packages/smart-crowd-simple-sms-drivers)

PHPackages © 2026

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