This is a PHP 7.3+ library to make it easier to fetch and use weather alerts created by NOAA.
Include noaa-cap-alerts into your project:
composer require thtroyer/noaa-cap-alerts
composer update
Make sure you have the XML extension installed for PHP.
e.g. sudo apt install php7.4-xml
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.