I am trying to include an external PHP library inside my Magento 2 module, specifically the eKomi PHP library (https://github.com/ekomi-dev/ekomi-api).
I have added the PHP files into the module so the folder structure looks like:
MyName
MyModule
Ekomi
Request
..
Service
..
Api.php
etc
..
Helper
..
composer.json
registration.php
My composer.json file looks like this:
{
"name": "MyName/MyModule",
"description": "N/A",
"require": {
"php": "~5.5.22|~5.6.0|~7.0.0"
},
"type": "magento2-module",
"version": "1.0.0",
"license": [
"OSL-3.0",
"AFL-3.0"
],
"autoload": {
"files": [
"registration.php"
],
"psr-4": {
"Magento\\Catalog\\": "",
"Ekomi\\": "Ekomi/"
}
}
}
When I run php bin/magento setup:di:compile
I am getting PHP include errors inside my Ekomi directory, I do not think I am including the files correctly inside my composer.json file.
The error message:
Compilation was started.
Proxies code generation... 0/7 [>---------------------------] 0% 1 sec 46.0 Mi
Proxies code generation... 1/7 [====>-----------------------] 14% 1 sec 50.0 Mi
Repositories code generation... 1/7 [====>-----------------------] 14% 1 sec 500 MiB
PHP Fatal error: Class 'Ekomi\Request\AbstractRequest' not found in /var/www/magento2/app/code/MyName/MyModule/Ekomi/Request/GetProduct.php on line 8