brookedot / weather-machine
PHP wrapper for the Weather Machine API
v1.0.1
2025-12-15 02:48 UTC
Requires
- php: ^8.2
- symfony/http-client: ^7.0|^8.0
README
A PHP wrapper for the Weather Machine API.
Uses Sympfony HTTP Client.
Installation
composer require brookedot/weather-machine
Usage
use BrookeDot\WeatherMachine\WeatherMachine; $weather = new WeatherMachine('your-api-key'); // Get hourly forecast $hourly = $weather->location(47.608013, -122.335167) ->source('mock') ->units('si') ->hourly(); // Get current conditions $current = $weather->location(47.608013, -122.335167) ->source('open_weather') ->currently(); // Get daily forecast $daily = $weather->location(47.608013, -122.335167) ->source('open_weather') ->daily();
Available Methods
Required
location(float $lat, float $lon)- Set coordinatessource(string $source)- Set weather data source (defaults to 'mock')
Optional
units(string $unit)- Set units: us, si, ca, uk, m (default: us)output(string $format)- Set output format: base, full (default: base)
Data Retrieval
get()- Get full responsecurrently()- Get current conditionshourly()- Get hourly forecastdaily()- Get daily forecastminutely()- Get minutely forecastalerts()- Get weather alerts
Available Sources
- accuweather
- aeris_weather
- apple_weather
- custom_weather
- foreca
- mock
- open_weather
- pirate_weather
- the_weather_company
- tomorrow_io
- visual_crossing
- weatherbit
License
AGPL V3 or later License - see LICENSE file for details.