Download the PHP package happy-types/money-type without Composer

On this page you can find all versions of the php package happy-types/money-type. 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 money-type

Money library

This library adds a new type Money which abstracts a real money object. Money has an Value and Currency. Without Money object you must store these values in separate variables like $amount, $currency. Its really hard to produce nice API methods without money object.

Example:

Should it return value or object ?

or better?

now you can apply some mathematics to money object:

or add and convert to some currency in same time

or with mutiple currencies ? wha?

comparing moneys with different currencies ?

To enable currency conversion you must implement interface and register it to using:

Implementation example of can be found at

Money

Class Money is a Value Object which means that all operations will create new instance of Money and all instances are immutable

This class is used in all system to describe money value. It is {amount, currency} tuple.

Methods , , , will implicitly convert specified argument into appropriate currency.

For currency conversion you can implement interface and register your money converter using

Default decimal precision is 4 digits

You can compare only two objects with exact the same precisions. All operations will use highest precisions of available operands.

use static factory to create Money instances. don`t use constructors directly!

amount must be specified in string type and decimal separator must be a dot (e.g. "123.45") You cannot specify or . only <- string, and dot separated number

Money amount must be string type only. Number must be dot separated. e.g. "123.45" not "123,45" (bc limitation) You cannot use float or integer types. Its defensive restriction to ensure that you wont loose precision accidentaly. In case if you want to specify integers or floats or string you can use Money::undefined($currency = '', $precision = -1)Money::create(false)Money::create(null)Money::create('')` e.g. Money::create('') === Money::undefined(); Money::create('0.00') !== Money::undefined(); isDefined()isUndefined() a = Money::create('10.00', 'LTL') b = a->convertTo('USD')->convertTo('LVL')->convertTo('LTL'); isEqualExact()add()subtract()Money::setDefaultCurrency($defaultCurrency)composer.json`` "require": { "happy-types/money-type" : "~1.1" } } composer update require_once(dirname(FILE).'/vendor/autoload.php'); ```

example is for index.php which is in project root folder.


All versions of money-type with dependencies

PHP Build Version
Package Version
Requires php Version >=5.2.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 happy-types/money-type contains the following files

Loading the files please wait ....