Download the PHP package tuxonice/ipma-api without Composer

On this page you can find all versions of the php package tuxonice/ipma-api. 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 ipma-api

IPMA-API

Latest Version on Packagist GitHub Tests Action Status Total Downloads License

This PHP package provides an easy-to-use interface for the IPMA (Instituto Português do Mar e da Atmosfera, I. P.) API. It allows you to fetch weather forecasts, observation data, and other auxiliary information directly into your PHP application.

For more information about the official API, please visit https://api.ipma.pt/ (only in Portuguese).

[!IMPORTANT] This package is unofficial and IS NOT affiliated with, endorsed by, or maintained by Instituto Português do Mar e da Atmosfera, I. P. (IPMA, I.P.) It only provides a PHP client for the public API available at https://api.ipma.pt/.

Warning: This is a work in progress package! While it is actively maintained, some features may be incomplete or subject to change.

Getting Started

Prerequisites

Installation

composer require tuxonice/ipma-api


Usage

Heads up — breaking change: every factory now requires a PSR-16 Psr\SimpleCache\CacheInterface. This is intentional: IPMA asks consumers not to hammer their endpoints, and most of them change infrequently (locations, stations, forecasts). See Caching responses (PSR-16) below for setup.

Here are a few examples of how to use this package. All snippets assume $cache is a Psr\SimpleCache\CacheInterface instance (e.g. a Symfony\Component\Cache\Psr16Cache backed by any PSR-6 adapter).

Get Daily Weather Forecast

Get Seismic Information

Get Weather Stations (Service)

All endpoints now return typed DTOs under Tlab\IpmaApi\Dto\*:

For more detailed examples and a full list of available endpoints, please see the documentation folder.


Caching responses (PSR-16)

IPMA asks consumers to avoid hitting their endpoints too often. To enforce this, a PSR-16 Psr\SimpleCache\CacheInterface is required by every factory and by ApiConnector itself — there is no unbounded-request mode.

Any PSR-16 implementation works. Using symfony/cache as an example:

Every factory accepts an optional int $ttlSeconds = 3600 as its second argument. You can also construct the connector directly:

Both JSON (fetchData) and CSV (fetchCsv) responses are cached. The raw CSV string is stored in cache and reconstructed as a Reader on hit. Cache keys are namespaced as ipma_api.<sha256(url)>.

Migrating from previous versions


Error handling

All errors raised by the library extend Tlab\IpmaApi\Exception\IpmaApiException:


Running Tests

This project uses PHPUnit for testing. To run the test suite, you can use the provided Makefile command:

To generate a code coverage report, run:

The report will be generated in the coverage/ directory.


Contributing

Contributions are welcome! If you would like to contribute to this project, please follow these steps:

  1. Fork the repository.
  2. Create a new branch for your feature or bug fix.
  3. Make your changes and commit them with a descriptive message.
  4. Push your changes to your fork.
  5. Submit a pull request to the main repository.

Please ensure that your code follows the existing coding style and that all tests pass before submitting a pull request.


Legal Notice

This package accesses data from the Instituto Português do Mar e da Atmosfera, I.P. (IPMA). When using this data, you must comply with IPMA's Terms and Conditions:

IPMA asks API users to read the usage conditions and to send an email to [email protected] informing them of the use and purpose of the service, for statistics and service improvement purposes.

The IPMA reserves the right to change or discontinue the API service at any time without notice.


All versions of ipma-api with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
ext-json Version *
symfony/http-client Version ^6.4 || ^7.0 || ^8.0
league/csv Version ^9.14
psr/simple-cache Version ^2.0 || ^3.0
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 tuxonice/ipma-api contains the following files

Loading the files please wait ...