mathsgod / hl-weather
This package is abandoned and no longer maintained.
The author suggests using the mathsgod/hko-weather package instead.
Hong Kong weather forecast
2.0.2
2020-09-03 03:03 UTC
Requires
- php: >=5.6
Requires (Dev)
- phpunit/phpunit: ^6.5
README
hl-weather
⚠️ This package is abandoned. Please use mathsgod/hko-weather instead.
composer require mathsgod/hko-weather
A PHP library for fetching Hong Kong weather forecasts from the Hong Kong Observatory Open Data API.
Requirements
- PHP >= 5.6
- Composer
Installation
composer require mathsgod/hl-weather
Usage
use HL\Weather; // English (default) $w = new Weather(); print_r($w->forecast()); // Traditional Chinese $w = new Weather('tc'); print_r($w->forecast()); // Simplified Chinese $w = new Weather('sc'); print_r($w->forecast());
forecast() return format
Each entry in the returned array contains:
| Key | Description |
|---|---|
date |
Date in YYYY-MM-DD format |
low |
Minimum temperature |
high |
Maximum temperature |
unit |
Temperature unit (e.g. C) |
forecastWind |
Wind description |
forecastWeather |
Weather description |
forecastIcon |
Weather icon code |
Returns 9 days of forecast data.
Example output
Array
(
[0] => Array
(
[date] => 2026-03-18
[low] => 21
[high] => 26
[unit] => C
[forecastWind] => East force 2 to 3.
[forecastWeather] => Mainly cloudy. One or two light rain patches at first. Warm with sunny periods during the day. Coastal mist at night.
[forecastIcon] => 51
)
[1] => Array
(
[date] => 2026-03-19
[low] => 21
[high] => 27
[unit] => C
[forecastWind] => Light winds force 2.
[forecastWeather] => Sunny periods. Coastal fog in the morning. Rather warm during the day.
[forecastIcon] => 83
)
...
)
Testing
composer test
License
MIT