web-technologies/yii2-calculator

Calculator extension for yii2

1.1.1 2019-07-03 08:08 UTC

This package is auto-updated.

Last update: 2024-04-29 04:13:34 UTC


README

Calculator extension for yii2

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require web-technologies/yii2-calculator "*"

or add

"web-technologies/yii2-calculator": "*"

to the require section of your composer.json file.

Configuration

In config file

/config/web.php

Add math component

'components' => array(
        ...
        'math' => array(
        	 	'class' => 'webtechnologies\calculator\Math',
        		//'handlerClass' => 'namespace/to/customHandlerClass',  //optional parameter
        		),
		    )

Usage

Once the extension is installed, simply use it in your code by :

<?=Yii::$app->math->expr('( 5 + (5 * 6) - 3 + 4 * 4 ^ 6 + ( -3 * -5 * 4 + ( 3 / 34 + 1 * 3 + 6 - 3 + ( 4 / 2 ) ) ) ) * -1')?>
//output: -16484.088235294