Skip to main content

Getting Started

OpenWeatherMap PHP API is a PHP client for weather APIs from OpenWeatherMap.org.

This project aims to normalise the provided data and remove inconsistencies. It is not maintained by OpenWeatherMap and not an official API wrapper.

Please note that only the following APIs are supported:

I am open for pull requests to add support for other APIs from OpenWeatherMap as long as they do not require a paid subscription. That is because I have no means to test paid APIs without paying myself.

PHP Requirements

  • PHP 7.1 and later (including PHP 8) (if you are still on PHP 5.x, you'll have to use version 2.x of this library)
  • PHP json extension
  • PHP libxml extension
  • PHP simplexml extension

Installation

This project can be found on Packagist and is best installed using Composer:

composer require "cmfcmf/openweathermap-php-api"

Required PSR-17/-18 dependencies

You will also need to have two additional dependencies installed:

  1. A PSR-17 compatible HTTP factory implementation.
  2. A PSR-18 compatible HTTP client implementation.

I you are integrating this project into a PHP framework, it most likely already comes with these. Otherwise, go through the lists of implementations on Packagist and choose ones that fit your project:

If you don't know which to choose, try these:

composer require "http-interop/http-factory-guzzle:^1.0" \
"php-http/guzzle6-adapter:^2.0 || ^1.0"