2017 © Pedro Peláez
 

library bom-weather

PHP lib for accessing the Australian Bureau of Meteorology (BOM) weather forecasts and observations.

image

previousnext/bom-weather

PHP lib for accessing the Australian Bureau of Meteorology (BOM) weather forecasts and observations.

  • Monday, June 25, 2018
  • by kimpepper
  • Repository
  • 4 Watchers
  • 2 Stars
  • 0 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

BOM Weather

A PHP library for fetching data from the Australian Bureau of Meteorology API., (*1)

Installation

composer require previousnext/bom-weather php-http/discovery

The library requires a PSR-18 HTTP client and PSR-17 HTTP factories. We recommend using Guzzle., (*2)

Usage

Forecasts

$httpClient = new GuzzleHttp\Client(['base_uri' => 'http://www.bom.gov.au/']);
$requestFactory = new Http\Factory\Guzzle\RequestFactory();
$client = new BomClient($httpClient, $requestFactory, new NullLogger());
$forecast = $client->getForecast('IDN10031');

$issueTime = $forecast->getIssueTime();

$regions = $forecast->getRegions();
$metros = $forecast->getMetropolitanAreas();
$locations = $forecast->getLocations();

foreach ($locations as $location) {
  $aac = $location->getAac();
  $desc = $location->getDescription();

  /** @var \BomWeather\Forecast\ForecastPeriod[] $periods */
  $periods = $location->getForecastPeriods();

  // Usually 7 days of forecast data.
  foreach ($periods as $period) {
    $date = $period->getStartTime();
    $maxTemp = $period->getAirTempMaximum();
    $precis = $period->getPrecis();
  }
}

Observations

$httpClient = new GuzzleHttp\Client(['base_uri' => 'http://www.bom.gov.au/']);
$requestFactory = new Http\Factory\Guzzle\RequestFactory();
$client = new BomClient($httpClient, $requestFactory, new NullLogger());
$observationList = $client->getObservationList('IDN60901', '95757');

$refreshMessage = $observationList->getRefreshMessage();

// Get the latest observation.
$observation = $observationList->getLatest();
$rain = $observation->getRainSince9am();

// Station information.
$station = $observation->getStation();
$name = $station->getName();

// Temperature observations.
$temperature = $observation->getTemperature();
$airTemp = $temperature->getAirTemp();
$apparentTemp = $temperature->getApparentTemp();
$relativeHumidity = $temperature->getRealtiveHumidity();

// Wind observations.
$wind = $observation->getWind();
$direction = $wind->getDirection();
$speedKmh = $wind->getSpeedKmh();
$gustKmh = $wind->getGustKmh();

// Pressure observations.
$pressure = $observation->getPressure();
$qnh = $pressure->getQnh();
$meanSeaLevel = $pressure->getMeanSeaLevel();

Developing

PHP CodeSniffer, (*3)

./bin/phpcs

PHPUnit, (*4)

./bin/phpunit

PHPStan, (*5)

./bin/phpstan

The Versions

25/06 2018

dev-master

9999999-dev

PHP lib for accessing the Australian Bureau of Meteorology (BOM) weather forecasts and observations.

  Sources   Download

GPL-2.0-or-later

The Requires

 

The Development Requires

by Kim Pepper

25/06 2018

1.0.0-alpha1

1.0.0.0-alpha1

PHP lib for accessing the Australian Bureau of Meteorology (BOM) weather forecasts and observations.

  Sources   Download

GPL-2.0-or-later

The Requires

 

The Development Requires

by Kim Pepper