Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

harryx9x9's avatar

Unable to use Facebook PHP SDK with Lumen

I tried autoloading php sdk using psr 4 autoloading with composer. I keep getting a class not found error. In fact I can't seem to be able to use any packages from the vendor directory, regardless of how I want to load them. I must be missing something as in Laravel 4, I use the php sdk using autoloading in composer and it works perfectly. Please help.

0 likes
5 replies
harryx9x9's avatar

Oh and I know about composer dump-autoload and so on. It is not the case.

davorminchorov's avatar
Level 53

Did you import the class you are using use path/to/class;?

1 like
harryx9x9's avatar

Ok so here is how I understand it should work.. Correct me if I am wrong:

  1. add dependency for external package in composer.json
  2. add path to package in psr4 autoload section such as "Facebook\": "/vendor/facebook/php-sdk-v4/src/Facebook"
  3. use facebook in the application like use \Facebook\Facebook

Now this works and it seems there is an issue with PHP SDK from facebook as FB released a v5 of their php sdk but the pacakge still says v4 to confuse everyone.

harryx9x9's avatar

So everything is good. I was tripping out. I will give you credit since you answered so fast. :)

1 like
davorminchorov's avatar

You don't have to add the path to package in PSR4 Autoload section. It will automatically be loaded when you use it in your app folder somewhere. (or any other class autoloaded inside composer.json)

Please or to participate in this conversation.