3
votes

i'm confused about composer. I read in other post "Every package should be responsible for autoloading itself" but i can't resolve the problem.

i have this composer.json file in root project folder:

{
    "require": {
        "facebook/php-sdk-v4": "4.0.*"
    }
}

I run composer install and it creates this structure:

vendor/
|-- autoload.php
|-- composer
|   |-- autoload_classmap.php
|   |-- autoload_namespaces.php
|   |-- autoload_real.php
|   |-- ClassLoader.php
|   `-- installed.json
`-- facebook
    `-- php-sdk-v4
        |-- autoload.php
        |-- composer.json
        |-- CONTRIBUTING.md
        |-- LICENSE
        |-- phpunit.xml.dist
        |-- README.md
        |-- src
        |   `-- Facebook
        |       |-- Entities
        |       |   |-- AccessToken.php
        |       |   `-- SignedRequest.php
        |       |-- FacebookAuthorizationException.php
        |       |-- FacebookCanvasLoginHelper.php
        |       |-- FacebookClientException.php
        |       |-- FacebookJavaScriptLoginHelper.php
        |       |-- FacebookOtherException.php
        |       |-- FacebookPageTabHelper.php
        |       |-- FacebookPermissionException.php
        |       |-- FacebookRedirectLoginHelper.php
        |       |-- FacebookRequestException.php
        |       |-- FacebookRequest.php
        |       |-- FacebookResponse.php
        |       |-- FacebookSDKException.php
        |       |-- FacebookServerException.php
        |       |-- FacebookSession.php
        |       |-- FacebookSignedRequestFromInputHelper.php
        |       |-- FacebookThrottleException.php
  [...]

vendor/facebook/php-sdk-v4/composer.json file shows:

"autoload": {
    "psr-4": {
        "Facebook\\": "src/Facebook/"
    }
}

and autoload_classmap.php and autoload_namespaces.php return empty arrays.

When run index.php throws this error:

PHP Fatal error: Class 'Facebook\FacebookSession' not found on line 33

require 'vendor/autoload.php';

use Facebook\FacebookSession;
use Facebook\FacebookRequest;
use Facebook\GraphUser;
use Facebook\FacebookRequestException;

FacebookSession::setDefaultApplication('x','y');

I don't know if i have to put in this files (in this arrays that are returned) or composer must include them automatically. Can Composer autoload classes declared in file vendor/facebook/php-sdk-v4/composer.json?

Thank you in advance, i really appreciate help

1
Perhaps try installing deps again. It works fine for mePhil
Thank you Phil! I have updated composer and installed deps again and now it works!Diomedes
Another happy customer :)Phil
If you solved your problem yourself, answer your question and set it as accepted answer.Gerd K

1 Answers

0
votes

Solved, i have updated composer and deps and works.

Thank you!