简体   繁体   中英

Adding 3rd party custom library in Yii2

I have a tax library avalara. How can I add it using Yii2. I have tried in putting in Vendor folder. used

require "/vendor/avalara/avalara.php"

it does include the file does wasn't able to call the functions inside it.

I have used the avalara library. Extract the file and put the AvaTax and autoload foler in vendor. Add the a class file in model directory.

$base_path = str_replace("frontend", "", \\Yii::$app->basePath);

require_once $base_path . 'vendor/avalara/vendor/autoload.php';

use Yii;

use AvaTax\\Address;

use AvaTax\\DetailLevel;

use AvaTax\\GetTaxRequest;

use AvaTax\\Line;

use AvaTax\\TaxServiceSoap;

use AvaTax\\ATConfig;

use AvaTax\\CancelTaxRequest;

After that create custom functions and use them in controller.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM