The easiest way to install Facebook PHP SDK on Magento 2 is to use the composer. Run this CLI command, in Magento 2 folder to install it:
composer require facebook/graph-sdk
If for some reason you cannot use the composer, then:
1. Download SDK version from Github.
2. Unzip archive.
3. Copy the folder
php-graph-sdk-5.6.3/src/Facebook
from the arcive to
path_to_magento2/lib/internal/Facebook
3. Edit file
path_to_magento2/app/etc/registration_globlist.php
and add a new line to the file, e.g.:
return [
'app/code/*/*/cli_commands.php',
'app/code/*/*/registration.php',
'app/design/*/*/*/registration.php',
'app/i18n/*/*/registration.php',
'lib/internal/*/*/registration.php',
'lib/internal/*/*/*/registration.php',
'setup/src/*/*/registration.php',
'lib/internal/Facebook/autoload.php', //new line
];
4. If registration_globlist.php does not exist, edit the file
path_to_magento2/app/etc/NonComposerComponentRegistration.php
and before
foreach ($pathList as $path) {
add this line of code
$pathList[] = dirname(dirname(__DIR__)) . '/lib/internal/Facebook/autoload.php';
Using Composer (Recommended)
Run the command composer require facebook/graph-sdk in your Magento 2 folder.
2. Without Composer (Manual Installation)
This completes the SDK integration in Magento 2.