Skip to content

PHP 7, PSR-6,17,18, UVIndex Improvements

Compare
Choose a tag to compare
@cmfcmf cmfcmf released this 09 Jun 06:51
45fab12

Version 3 comes with a few bug fixes and new and removed features.

  • [Breaking]: The minimum required PHP version is now PHP 7.0
  • [Breaking]: Support for the Weather History API has been removed. It is unfortunately not possible for me to test the integration, because it requires a paid API key.
  • [Breaking]: Caching OWM responses no longer uses a custom cache implementation (Cmfcmf\OpenWeatherMap\AbstractCache) but instead PSR-6 compatible caches.
  • [Breaking]: Custom Cmfcmf\OpenWeatherMap\Fetcher\FetcherInterface classes dropped in favor of PSR-18 compatible HTTP clients. You now need to pass a PSR-18 compatible HTTP client as well as a PSR-17 compatible HTTP request factory to the OpenWeatherMap constructor. You will need to choose and install two additional dependencies separately:
    1. A PSR-17 compatible HTTP factory implementation.
      A list of HTTP factory implementations is available at Packagist.
    2. A PSR-18 compatible HTTP client implementation.
      A list of HTTP client implementations is available at Packagist.

Example for Guzzle (php-http/guzzle6-adapter, http-interop/http-factory-guzzle):

use Http\Factory\Guzzle\RequestFactory;
use Http\Adapter\Guzzle6\Client as GuzzleAdapter;

$httpRequestFactory = new RequestFactory();
$httpClient = GuzzleAdapter::createWithConfig([]);
$owm = new OpenWeatherMap($myApiKey, $httpClient, $httpRequestFactory);
  • [Breaking]: Removal of long-deprecated getRawData() method. Use getRawWeatherData instead.
  • [Breaking]: The units for temperatures previously were K, °C and F. Now they are K, °C and °F.
  • [Breaking]: The UV index API has been expanded to support historic uv index data and forecast UV index data: getCurrentUVIndex, getForecastUVIndex and getHistoricUVIndex (thanks to @roelvanhintum).
  • ext-json, ext-libxml and ext-simplexml have always been implicitly required, but are now explicitly required in composer.json (thanks to @gloomy).