At the moment I'm developing a module for Magento 2. I'm using a third party library ("twizo/lib-api-php") and installed it using composer. When I use a class from this library, Magento gives me the error "Class Twizo\Api\Twizo' not found". How can I autoload the files from this vendor directory? My composer.json file looks like this now:

  "name": "twizo/authentication",
  "type": "magento2-module",
  "version": "0.1.0",
  "autoload": {
    "psr-4": {
      "Twizo\\Authentication\\": ""
    "files": [
  "require": {
    "twizo/lib-api-php": "^0.10.0"

When I remove the files section of composer.json it works. But according to the Magento package validation tool each module's composer.json file has to contain a field section so that's no really an option.

If I require the autoload.php file manually like this: require __DIR__ . '\..\..\..\vendor\autoload.php';, Magento gives the error that my module is already defined, so I think it will do the autoload twice. How can I fix this?

Module 'Twizo_Authentication' from 'C:\xampp\htdocs\magento\app\code\Twizo\Authentication' has been already defined in 'C:/xampp/htdocs/magento/app/code/Twizo/Authentication'.

1 Answer 1


I used this [https://magento.stackexchange.com/questions/103188/magento2-how-to-include-third-pary-module-through-composer-json-in-custom-modul]

Magento2: How to include third pary module through composer.json in custom module and it worked fine for me. I was running composer install in the wrong directory.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.