web-technologies / yii2-calculator
Calculator extension for yii2
Installs: 17
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
Type:yii2-extension
Requires
- yiisoft/yii2: ~2.0.0
This package is auto-updated.
Last update: 2025-03-29 00:59:26 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