class Facebook not found in laravel 5 facebook graph api
Within the index function, you are not in the global scope so that as you call the class as Facebook\Facebook
, PHP thinks that you are calling Facebook\Facebook
declared in the App\Http\Controllers\Userapp
namespace.
Either you need to reference them as globally like below with prepending \
.
public function index(){ $fb = new \Facebook\Facebook([]); // your code catch(\Facebook\Exceptions\FacebookResponseException $e) // your code catch(\Facebook\Exceptions\FacebookSDKException $e) // your code}
Or use the aliases.
use Facebook\Facebook as Facebook;use Facebook\Exceptions\FacebookResponseException as FacebookResponseExceptionuse Facebook\Exceptions\FacebookSDKException as FacebookSDKExceptionpublic function index(){ $fb = new Facebook([]); // your code catch(FacebookResponseException $e) // your code catch(FacebookSDKException $e) // your code }