I have opened an issue in the stack exchange, reference: Issue 117979
I have been having trouble completing tutorial on creating integration from the config.
I believe I followed all the steps correctly. Please help me find the reason why the integration won't appear as expected.
Project structure
Placed in vendor directory of Magento root directory.
somevendor
└── module-somemodule
├── Setup
│ └── InstallData.php
├── composer.json
├── etc
│ ├── integration
│ │ ├── api.xml
│ │ └── config.xml
│ └── module.xml
└── registration.php
I decided to name my example vendor as `Somevendor` and module as `Somemodule` just for testing purposes.
composer.json
{
"name": "Somevendor_Somemodule",
"description": "create integration from config",
"require": {
"php": "~5.5.0|~5.6.0|~7.0.0",
"magento/framework": "2.0.0",
"magento/module-integration": "2.0.0"
},
"type": "magento2-module",
"version": "1.0",
"autoload": {
"files": [ "registration.php" ],
"psr-4": {
"Somevendor\\Somemodule\\": ""
}
}
}
registration.php
<?php
\Magento\Framework\Component\ComponentRegistrar::register(
\Magento\Framework\Component\ComponentRegistrar::MODULE,
'Somevendor_Somemodule',
__DIR__
);
etc/module.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Somevendor_Somemodule" setup_version="2.0.0">
<sequence>
<module name="Magento_Integration"/>
</sequence>
</module>
</config>
etc/integration/api.xml
<integrations>
<integration name="testIntegration">
<resources>
<!-- To grant permission to Magento_Log::online, its parent Magento_Customer::customer needs to be declared as well-->
<resource name="Magento_Customer::customer" />
<resource name="Magento_Log::online" />
<!-- To grant permission to Magento_Sales::reorder, all its parent resources need to be declared-->
<resource name="Magento_Sales::sales" />
<resource name="Magento_Sales::sales_operation" />
<resource name="Magento_Sales::sales_order" />
<resource name="Magento_Sales::actions" />
<resource name="Magento_Sales::reorder" />
</resources>
</integration>
</integrations>
etc/integration/config.xml
<integrations>
<integration name="TestIntegration">
<email>someone@example.com</email>
<endpoint_url>http://example.com</endpoint_url>
<identity_link_url>http://example.com/identity</identity_link_url>
</integration>
</integrations>
Setup/InstallData.php
<?php
namespace Somevendor\Somemodule\Setup;
use Magento\Framework\Setup\ModuleContextInterface;
use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Integration\Model\ConfigBasedIntegrationManager;
use Magento\Framework\Setup\InstallDataInterface;
class InstallData implements InstallDataInterface
{
/**
* @var ConfigBasedIntegrationManager
*/
private $integrationManager;
/**
* @param ConfigBasedIntegrationManager $integrationManager
*/
public function __construct(ConfigBasedIntegrationManager $integrationManager)
{
$this->integrationManager = $integrationManager;
}
/**
* {@inheritdoc}
*/
public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
{
$this->integrationManager->processIntegrationConfig(['testIntegration']);
}
}
Local setup
I couldn't put entire config as post length is limited to 30000 characters but I will put specific information if requested.
PHP Version => 5.5.30
System => Darwin rutherfordium.local 15.2.0 Darwin Kernel Version 15.2.0: Fri Nov 13 19:56:56 PST 2015; root:xnu-3248.20.55~2/RELEASE_X86_64 x86_64
Build Date => Dec 4 2015 19:25:34
Configure Command => './configure' '--prefix=/Applications/XAMPP/xamppfiles' '--with-apxs2=/Applications/XAMPP/xamppfiles/bin/apxs' '--with-config-file-path=/Applications/XAMPP/xamppfiles/etc' '--with-mysql=mysqlnd' '--enable-inline-optimization' '--disable-debug' '--enable-bcmath' '--enable-calendar' '--enable-ctype' '--enable-ftp' '--enable-gd-native-ttf' '--enable-magic-quotes' '--enable-shmop' '--disable-sigchild' '--enable-sysvsem' '--enable-sysvshm' '--enable-wddx' '--with-gdbm=/Applications/XAMPP/xamppfiles' '--with-jpeg-dir=/Applications/XAMPP/xamppfiles' '--with-png-dir=/Applications/XAMPP/xamppfiles' '--with-freetype-dir=/Applications/XAMPP/xamppfiles' '--with-zlib=yes' '--with-zlib-dir=/Applications/XAMPP/xamppfiles' '--with-openssl=/Applications/XAMPP/xamppfiles' '--with-xsl=/Applications/XAMPP/xamppfiles' '--with-ldap=/Applications/XAMPP/xamppfiles' '--with-gd' '--with-imap=/bitnami/xamppunixinstallerstack-osx-x64/src/imap-2007e' '--with-imap-ssl' '--with-gettext=/Applications/XAMPP/xamppfiles' '--with-mssql=shared,/Applications/XAMPP/xamppfiles' '--with-pdo-dblib=shared,/Applications/XAMPP/xamppfiles' '--with-sybase-ct=/Applications/XAMPP/xamppfiles' '--with-mysql-sock=/Applications/XAMPP/xamppfiles/var/mysql/mysql.sock' '--with-oci8=shared,instantclient,/Applications/XAMPP/xamppfiles/lib/instantclient' '--with-mcrypt=/Applications/XAMPP/xamppfiles' '--with-mhash=/Applications/XAMPP/xamppfiles' '--enable-sockets' '--enable-mbstring=all' '--with-curl=/Applications/XAMPP/xamppfiles' '--enable-mbregex' '--enable-zend-multibyte' '--enable-exif' '--with-bz2=/Applications/XAMPP/xamppfiles' '--with-sqlite=shared,/Applications/XAMPP/xamppfiles' '--with-sqlite3=/Applications/XAMPP/xamppfiles' '--with-libxml-dir=/Applications/XAMPP/xamppfiles' '--enable-soap' '--with-xmlrpc' '--enable-pcntl' '--with-mysqli=mysqlnd' '--with-pgsql=shared,/Applications/XAMPP/xamppfiles/' '--with-iconv=/Applications/XAMPP/xamppfiles' '--with-pdo-mysql=mysqlnd' '--with-pdo-pgsql=/Applications/XAMPP/xamppfiles/postgresql' '--with-pdo-sqlite' '--with-icu-dir=/Applications/XAMPP/xamppfiles' '--enable-fileinfo' '--enable-phar' '--enable-zip'
Server API => Command Line Interface
Virtual Directory Support => disabled
Configuration File (php.ini) Path => /Applications/XAMPP/xamppfiles/etc
Loaded Configuration File => /Applications/XAMPP/xamppfiles/etc/php.ini
Scan this dir for additional .ini files => (none)
Additional .ini files parsed => (none)
PHP API => 20121113
PHP Extension => 20121212
Zend Extension => 220121212
Zend Extension Build => API220121212,NTS
PHP Extension Build => API20121212,NTS
Debug Build => no
Thread Safety => disabled
Zend Signal Handling => disabled
Zend Memory Manager => enabled
Zend Multibyte Support => provided by mbstring
IPv6 Support => enabled
DTrace Support => disabled
Registered PHP Streams => https, ftps, compress.zlib, compress.bzip2, php, file, glob, data, http, ftp, phar, zip
Registered Stream Socket Transports => tcp, udp, unix, udg, ssl, sslv3, sslv2, tls
Registered Stream Filters => zlib.*, bzip2.*, convert.iconv.*, mcrypt.*, mdecrypt.*, string.rot13, string.toupper, string.tolower, string.strip_tags, convert.*, consumed, dechunk
This program makes use of the Zend Scripting Language Engine:
Zend Engine v2.5.0, Copyright (c) 1998-2015 Zend Technologies
_______________________________________________________________________
Configuration
bcmath
BCMath support => enabled
Directive => Local Value => Master Value
bcmath.scale => 0 => 0
bz2
BZip2 Support => Enabled
Stream Wrapper support => compress.bzip2://
Stream Filter support => bzip2.decompress, bzip2.compress
BZip2 Version => 1.0.6, 6-Sept-2010
calendar
Calendar support => enabled
Core
PHP Version => 5.5.30
Directive => Local Value => Master Value
allow_url_fopen => On => On
allow_url_include => Off => Off
always_populate_raw_post_data => Off => Off
arg_separator.input => & => &
arg_separator.output => & => &
asp_tags => Off => Off
auto_append_file => no value => no value
auto_globals_jit => On => On
auto_prepend_file => no value => no value
browscap => no value => no value
default_charset => no value => no value
default_mimetype => text/html => text/html
disable_classes => no value => no value
disable_functions => no value => no value
display_errors => STDOUT => STDOUT
display_startup_errors => On => On
doc_root => no value => no value
docref_ext => no value => no value
docref_root => no value => no value
enable_dl => Off => Off
enable_post_data_reading => On => On
error_append_string => no value => no value
...
Magento version
2.0.4
Building
Clean-up the build
rm -rf var/di
Or
rm -rf var/cache/* var/di/* var/generation/* var/page_cache/*
Launch the upgrade
/Applications/XAMPP/bin/php bin/magento setup:upgrade
Build
/Applications/XAMPP/bin/php bin/magento setup:di:compile
Note that I am using /Applications/XAMPP/bin/php instead of simply php because I want to be sure this is same runtime as locally running server.
I completed several other examples, for custom API endpoint and observers, those worked fine with same approach and debug logging, only integration causes trouble.
Obtained results
Integration does not appear in the admin panel as tutorial suggests it should.
Attempts to explain
I failed to put logger in the InstallData.php script as I tried to determine if it is being launched or not. The reason why it didn't work is actually a subject for opening a separate issue.
Maybe someone could advise if there is a better way to test that, it would be a good start.