1

As an example, I'm looking to use Zendesk's API to create tickets and other things within my custom modules. They have a Packagist that can be installed via composer:

composer require zendesk/zendesk_api_client_php

Now I'm a bit confused on how to actually call or load this API in my custom module(s).

For example, how would you call the Zendesk API library in a custom observer module:

<?php
namespace MyCompany\MyModule\Observer;

use Magento\Framework\Event\ObserverInterface;

class SalesOrderShipmentSaveAfter implements ObserverInterface
{
  public function execute(\Magento\Framework\Event\Observer $observer)
    {
         // Do something here using Zendesk API
    }
}

Is it declared in MyCompany/MyModule composer.json file?

  • Just call library funciton by $value = \Zendesk\Myfile::functionName() – Prince Patel Mar 15 '18 at 5:25
0

Yes, your modules composer.json should read the json file and be added to it's autoloader.

This library should be shipped as a part of your custom module. Specify path to autoload.php of generated library in composer.json of your module. Should have something like this:

{ ... "autoload": { "files": [ "registration.php", "path-to-generated-soap-client-lib-autoload.php" ], ... } }

0

you can include third party class file to top of registration.php file like this

require_once(BP . "/magmi/inc/magmi_defs.php"); 
require_once(BP . "/magmi/integration/inc/magmi_datapump.php"); 

and then you can direct access function like

$dp = \Magmi_DataPumpFactory::getDataPumpInstance("productimport");

in controller or model

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.