Download the PHP package meteosource/meteosource_php without Composer

On this page you can find all versions of the php package meteosource/meteosource_php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package meteosource_php

meteosource - Weather API library

PHP wrapper library for Meteosource weather API that provides detailed hyperlocal weather forecasts for any location on earth.

Installation

Install using Composer.

Get started

To use this library, you need to obtain your Meteosource API key. You can sign up or get the API key of existing account in your dashboard.

Library usage

Initialization

To initialize the Meteosource object, you need your API key and the name of your subscription plan (tier). Basic example of initialization is shown below:

Get the weather data

Using meteosource library, you can get weather forecasts or archive weather data (if you have a paid subscription).

Forecast

To get the weather data for given place, use getPointForecast() method of the Meteosource object. You have to specify either the coordinates of the place (lat + lon) or the place_id. Detailed description of the parameters can be found in the API documentation.

Note that the default timezone is always UTC, as opposed to the API itself (which defaults to the point's local timezone). This is because the library always queries the API for the UTC timezone to avoid ambiguous datetimes problems. If you specify a different timezone, the library still requests the API for UTC, and then converts the datetimes to desired timezone.

Historical weather

Users with paid subscription to Meteosource can retrieve historical weather from time_machine endpoint, using getTimeMachine() method:

Note, that the historical weather data are always retrieved for full UTC days. If you specify a different timezone, the datetimes get converted, but they will cover the full UTC, not the local day. If you specify a datetime to any of the date parameters, the hours, minutes, seconds and microseconds get ignored. So if you request '2021-12-25T23:59:59', you get data for full UTC day 2021-12-25.

If you pass array of dates to date parameter, they days will be inserted into the inner structures in the order they are being iterated over. This affects time indexing by integer (see below). An API request is made for each day, even when you specify a date range.

Working with the weather data

All of the meteosource's data objects have overloaded __toString() methods, so you can echo the objects to get useful information about them:

Attribute access

The library loads the JSON response into its internal structures. You can access the attributes using the object operator (->), or the index operator ([]):

Weather data sections

There are 5 weather forecast sections (current, minutely, hourly, daily and alerts) as attributes in the Forecast object.

The current data contains data for many variables for a single point in time (it is represented by SingleTimeData object):

The minutely, hourly and daily sections contain forecasts for more points in time (represented by MultipleTimesData). The sections that were not requested are empty (null):

The sections that were requested can also be echoed, to view number of available timesteps and their range (inclusive):

The alerts section contain meteorological alerts and warnings, if there are any issued for the location. The alerts object is an instance of AlertsData class. You can echo the object or iterate over it:

You can also get list of all active alerts for given time. If you use string or tz-naive DateTime in this function, it will suppose that it is in the same timezone as requested for the forecast.

There is a single section data for historical weather as an attribute in the TimeMachine object, represented by MultipleTimesData.

Time indexing

As mentioned above, the minutely, hourly, daily sections of Forecast and the data section of TimeMachine contain data for more timesteps. To get the data for a single time, you have several options.

1. Indexing with integer

You can simply index an instance of MultipleTimesData with integer, as the offset from the current time:

2. Indexing with string

To get the exact time, you can use string in YYYY-MM-DDTHH:00:00 format. The datetime string is assumed to be in the same timezone as the data.

3. Indexing with datetime

You can also use DateTime as an index, it is automatically converted to the timezone of the data.

Note: minutely, hourly, daily and alerts are of ArrayIterator type

Variable access

To access the variable, you can need to use the object operator (->):

Some variables are grouped into logical groups, just like in the API response. You can access the actual data with chained object operators (->) operators:

Tests

The unit tests are written using PHPUnit. You need to provide your actual API key using environment variable. To run the tests, use:

Contact us

You can contact us here.


All versions of meteosource_php with dependencies

PHP Build Version
Package Version
Requires php Version >=7.2
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package meteosource/meteosource_php contains the following files

Loading the files please wait ....