Search code examples
phpdependenciescomposer-phpautoloadpackagist

Composer library can't find dependency


I made my first php library available through packagist. I'm still figuring out how it works, but I keep getting this exception:

Fatal error: Uncaught Error: Class 'Waspeer\NextAction\FabianBeiner\Todoist\TodoistClient' not found in /home/deb58323n2/domains/wannessalome.nl/public_html/assets/todoist/vendor/waspeer/todoist-next-action/src/NextAction.php:120

I listed FabianBeiner\Todoist as a dependency in my composer.json:

"require": {
    "php": ">=7.1.0",
    "fabian-beiner/todoist-php-api-library": "^0.7.2"
},
"autoload": {
    "psr-4": {
        "Waspeer\\NextAction\\": "src/"
    }
}

And this is in my library file:

namespace Waspeer\NextAction;

use FabianBeiner\Todoist\TodoistClient;

It seems like it's trying to find the dependency in the folder of my library, but I don't know why and how to solve this. Any ideas?


Solution

  • Solved it! When I changed new FabianBein\Todoist\TodoistClient later in the code to just new TodoistClient it worked. Guess I don't really get yet how this use statement/autoloading works..