Download the PHP package sourcepot/asset without Composer

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

Installation

You can use Packagist to install the package on a web server or your lacal computer, e.g. Command Prompt, enter composer create-project sourcepot/asset {add your target directory here}.

The following code examples require the namespace to be set to namespace SourcePot\Asset;.

Features

The Asset class

The asset class of this package can be used to create objects representing an asset. The main properties of such an asset are "value", "unit" and "dateTime", e.g. 1 (value) Euro (unit) on 12/03/2023. These three properties need to be provided to the contructor of a new asset object. If a different unit is set, the exchange rate is applied to the asset object and the dateTime will be updated to the excchange rate dateTime.

[!NOTE] European Central Bank exhchage rates are used. If an exchage rate is not yet present as csv-file in the data directory, it will be downloaded via the ECB API and saved to data directory. If an exchange rate is requested for a weekend (such as in the code sample below) or bank holiday, the latest valid exchange rate before that date will be used and a warning will be added as asset property.

The Asset class

Method \SourcePot\Asset\Asset::getArray() returns an array with derived asset properties including any warnings or errors.

An asset can be added to the asset object using the method \SourcePot\Asset\Asset::addAsset(float $value=0,string $unit=self::DEFAULT_UNIT,\DateTime $dateTime=NULL) and providing the respective asset properties. In the following example the asset is 100 EUR (2024-01-01T00:00:00+01:00) and an amount of 100 GBP is added on December 01, 2024:

Method \SourcePot\Asset\Asset::setFromString(string $string,string $unit=self::DEFAULT_UNIT,\DateTime $dateTime=NULL) provides a string parser. The method loads the asset derived from the string to the asset object. If the currency can't be derived, the default is used and if dateTime is not provided, DateTime('now') will be used.

The Rates class

The Rates class supports the Asset class with unit conversion. Currencies are subset of units. The following code example creates a Rates object and retunrs available currencies.

The DateTimeParser class

The DateTimeParser class provides methods for creating/updating a DateTime object from timestamps or strings. The following example creates a DateTimeParser object, sets a new state by parsing a string and outputs the DateTimeParser object. Since the setFromString() method is called without the timezone argument, the default timezone is used. The time zone is therefore changed from Asia/Tokyo to Europe/Berlin. The setFromString() method supports very different date/time formats. A timezone is only recognized in the string if the spelling corresponds exactly to a php time zone.

// the default timezone is Europe/Berlin, the parsed sting will return 2014-08-02T05:34:56+02:00 echo $asset;

Evaluation web page

An evaluation web page is provided with this package.

The webpage allows:

  1. flexible creation of an asset object,
  2. asset conversion to US-Dollars and
  3. adding yearly interest.

Here is a screenshot of the evaluation web page:


All versions of asset with dependencies

PHP Build Version
Package Version
Requires php Version >=8.0
moneyphp/money Version >=v4.6.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 sourcepot/asset contains the following files

Loading the files please wait ...