I'm trying to install and run the Facebook SDK on CodeIgniter using Composer.
CodeIgniter is installed and working nicely.
Composer support was added by doing the following:
curl -s http://getcomposer.org/installer | php
touch composer.json
- Added the require lines to the
composer.json
file ("facebook/php-sdk-v4" : "4.0.*"
) - Ran
composer update
All went to plan. Composer created a /vendor
folder, and the Facebook SDK is there.
I then added Composer support to CodeIgniter by adding the line include_once './vendor/autoload.php';
to the top of index.php
.
No errors at this point.
I'm now looking to call the SDK. I don't seem to be able to use any of the Facebook classes though. See below for things tried and failed...
var_dump(class_exists('Facebook'));
shows bool(false)
FacebookSession::setDefaultApplication('app id removed', 'app secret removed');
Spits out:
Fatal error: Class 'FacebookSession' not found in /var/sites/***/public_html/application/controllers/welcome.php on line 13
And a more full example:
<?php
class Welcome extends CI_Controller {
use Facebook\FacebookSession;
use Facebook\FacebookRequest;
use Facebook\GraphUser;
use Facebook\FacebookRequestException;
public function index()
{
FacebookSession::setDefaultApplication('app id removed', 'app secret removed');
}
}
Spits out:
Fatal error: Welcome cannot use Facebook\FacebookSession - it is not a trait in /var/sites/***/public_html/application/controllers/welcome.php on line 5