问题
I think this is related to the autoloading of Symfony2:
I created a
class FacebookSessionPersistence extends \BaseFacebook
Further, I inserted following line in the autoload.php:
$loader->registerPrefixes(array(
'Facebook' => __DIR__.'/../vendor/facebook/src',));
Still I get following error:
Fatal error: Class 'BaseFacebook' not found in /var/www/..../Bundle/Library/FacebookSessionPersistence.php on line 14
What should I do, to tell Symfony to load this class?
回答1:
Try class FacebookSessionPersistence extends Facebook\BaseFacebook
If this fails you'll need to explicitly include base_facebook.php file
You should also take a look at FOSFacebookBundle - it probably solves whatever you're trying to do. At least I know for sure that it has a fos_facebook.api
service, which is what you're trying to implement..
回答2:
Check your autoload_classmap.php
file, it should contain something like this
'BaseFacebook' => $vendorDir . '/facebook/php-sdk/src/base_facebook.php',
'Facebook' => $vendorDir . '/facebook/php-sdk/src/facebook.php',
'FacebookApiException' => $vendorDir . '/facebook/php-sdk/src/base_facebook.php',
if you installed the "facebook/php-sdk"
with composer, it should be done automatically.
来源:https://stackoverflow.com/questions/8398183/symfony2-using-facebook-php-api-basefacebook-class-can-not-be-loaded