0

I am working on a API integration in magento2. That API have two php file with there own functions, that I want to call in our controller to implement respective process. I have placed that API library files in parallel with our controller file like -

Our controller - app/code/Mycompany/CustomerAttribute/Controller/Coral/test.php

And library core php files -
app/code/Mycompany/CustomerAttribute/Controller/Coral/Lib/fileOne.php app/code/Mycompany/CustomerAttribute/Controller/Coral/Lib/fileTwo.php

in our test.php controller file I am calling above files as -

use Magento\Customer\Model\Url;
use Magento\Store\Model\ScopeInterface;
use Magento\Framework\Mail\Template\TransportBuilder;
use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Framework\App\Area;

use Magento\Framework\Event\ObserverInterface;

**require 'Lib/fileOne.php';**

and trying to create object like this -

$obj = new FileOne(array(
                        'appId' => $AppId,
                        'key' => $Key
                    ));

But after executing above statement its showing nothing;

Is this a right approach or I am doing something wrong in current method ?

0

You must need to use Standard way to Implement Libs,for Example how to include 3rd party library in magento 2 (like php xlsx library)

and that way you can access you function in your Extensions. with above way you can also update version of your lib.

| improve this answer | |

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.