Download the PHP package enis-sklep-opon/nbp-php without Composer

On this page you can find all versions of the php package enis-sklep-opon/nbp-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 nbp-php

nbp-php

API for accessing Polish National Bank (NBP - Narodowy Bank Polski) currency and commodities exchange rates.

Latest Version on Packagist Build Status Build Status No dependencies MIT License

Usage

Installing via composer

Minimal setup

Examples

All working examples from this README are included in the examples/ directory of the repository.

Services

CurrencyAverageRatesService

This service provides API for accessing average rates published in NBP tables.

fromMonth method

Returns flat collection of rates from all NBP tables at given month

fromDay method

Returns a dictionary with NBP tables from given day.

fromDayBefore method

Returns a dictionary with NBP tables from day before given day. This method can be useful in some bookkeeping applications when there is a legislatory need to calculate transfer prices. The legislation requires for the prices to be calculated using currency rate applied in the business day before the actual transfer date. Which is exactly what this method exposes.

Example:

getMonthTablesA method

Returns the A table iterator from a specific month. Rates here are grouped into tables, which represent the actual data structure provided by NBP. To get the rates there needs to be second iteration:

Example getting specific rate:

getMonthTablesB method

Returns the B table iterator from a specific month.

Warning about missing currencies in table B

In table B there can be multiple currencies with the same code.

It is also possible, that a specific currency is present in table from one day, but is not present in table from the next day.

In such case you should not use the getRate($rate) method but rather iterate over all currencies returned by getRates().

Currency trading rates service

This service is used to get buy and sell currency rates from NBP tables.

fromMonth method

Returns trading rates from entire month.

fromEffectiveDay method

Return rates from effective date.

fromTradingDay method

Return rates from trading date.

Gold rates service

This service is used to get gold commodity rates from NBP tables.

fromMonth method

Gets all rates from specific month.

fromDay method

Returns a gold rate from specific date.

fromDayBefore method

Returns a gold rate from before a specific date.

Using cache

Note that a library implementing PSR-6 has to be provided in order to use the caching abilities.

The CachedTransport class is a proxy for all other transport implementations. This transport has to be backed by another transport, as it relies on it to make the actual requests that have not been cached yet.

Example

Using custom transport

The library uses Symfony HTTP Client and Guzzle as default transports. If those packages are not available then it falls back to the file_get_contents method. This may not be ideal in some situations. Especially when there is no access to HTTP client packages as may be the case when using PHP version prior to 8.0.

In such cases it is suggested to use different transport. It can be achieved by replacing the TransportFactory of the NbpClient with your own implementation.

Layers

Service layer

The service consists of facades for the package. Classes here are named services instead of facades due to common understanding of this word as something through which you access the internals of a system.

This layer provides a high level business-oriented methods for interacting with the NBP API. It exposes most common use cases of the nbp-php package and is the likely starting point for all applications using this package. One needs to interact with other layers only for more complex tasks.

The service layer is structured in the way that it directly communicates with the repository layer.

Repository layer

Repository layer allows getting data from NBP API by providing methods that closely reflect the NBP Web API. This layer operates on higher level, hydrated domain objects.

The only constraint here is that the repository layer operates on month-based dates. So for example you can get trading rates from entire month, but in order to retrieve a specific date you have to iterate through the retrieved month (you can use service layer for that). This is by design for the purpose of reducing network traffic to the NBP servers. It also allows simplifying caching on the transport layer, because there is no need for any cache-pooling logic.

Client layer

Client layer is a bridge between the repository and the transport layer. It processes request objects on the input, and then it uses the transport layer to fulfill those requests.

The requests thet client layer uses are higher-level requests then those on the transport layer. They implement NbpClientRequest interface.

Transport layer

The transport layer is responsible for directly interacting with the NBP API. A few independent transport implementations are provided for serving connections to the NBP API.

It is also equipped with a convenient factories which pick the most appropriate implementation depending on installed libraries and configuration.


All versions of nbp-php with dependencies

PHP Build Version
Package Version
Requires php Version >=7.2||>=8.0
ext-json Version *
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 enis-sklep-opon/nbp-php contains the following files

Loading the files please wait ....