Skip to content

thtroyer/noaa-cap-alerts

Repository files navigation

thtroyer/noaa-cap-alerts

Build Status Code Coverage Scrutinizer Code Quality Latest Stable Version Latest Unstable Version License

What is this?

This is a PHP 7.3+ library to make it easier to fetch and use weather alerts created by NOAA.

Setup

Include noaa-cap-alerts into your project:

composer require thtroyer/noaa-cap-alerts
composer update

Dependencies

Make sure you have the XML extension installed for PHP.

e.g. sudo apt install php7.4-xml

Usage

Instantiate a new NoaaCapAlerts\NoaaAlerts object. Calling getAlerts() will download the latest alerts from NOAA, parse and return a set of data objects to be consumed.

$noaaAlerts = new NoaaCapAlerts\NoaaAlerts();
$alerts = $noaaAlerts->getAlerts();

foreach ($alerts as $alert) {
    echo $alert->getTitle();
}

See NoaaCapAlerts\Model\NoaaAlert class to see what data is currently available.

Features are still being added, so some changes may not be backwards compatible. Until 1.0, treat new feature versions (0.x) as breaking updates.

More information about NOAA's CAP format is available here.