Symfony2: using Facebook PHP Api, BaseFacebook class can not be loaded

只愿长相守 提交于 2019-12-13 04:01:31

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!