cancel
Showing results for 
Search instead for 
Did you mean: 

How to install Facebook PHP SDK on Magento 2?

How to install Facebook PHP SDK on Magento 2?

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';

 

1 REPLY 1

Re: How to install Facebook PHP SDK on Magento 2?

Using Composer (Recommended)
Run the command composer require facebook/graph-sdk in your Magento 2 folder.

2. Without Composer (Manual Installation)

  • Download the SDK from GitHub, unzip it, and copy the php-graph-sdk-5.6.3/src/Facebook folder to path_to_magento2/lib/internal/Facebook.
  • Edit path_to_magento2/app/etc/registration_globlist.php and add the line for Facebook/autoload.php.
  • If the file doesn’t exist, edit NonComposerComponentRegistration.php and add the path for Facebook/autoload.php before the path list is processed.

This completes the SDK integration in Magento 2.