Search code examples
yii2avalara

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.


Solution

  • 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.