1
votes

I recently started with TYPO3 and composer as a student. I'm kind of new to all this and I can't get my composer to autoload an api library from Mautic that I want to have. My code keeps telling me that it can't find the classes.

In my extension root directory I have composer.json and it looks like this

{
    "name": "woeler\/wlr_typo_mautic",
    "config": {
        "vendor-dir": "Libraries"
    },
    "description": "Typo3 to Mautic connection",
    "type": "typo3-cms-extension",
    "require": {
        "mautic\/api-library": "^2.6"
    },
    "autoload": {
        "psr-4": {
            "Woeler\\WlrTypoMautic\\": "Classes",
            "Mautic\\Auth\\": "Libraries\/mautic\/api-library\/lib\/Auth\/"
        }
    },
    "license": "MIT",
    "authors": [
        {
            "name": "MyName",
            "email": "[email protected]"
        }
    ]
}

I'm probably making a basic mistake, but the tutorials I can find are not really helping me. I have a class in the folder Classes/Controller and I want it to use a class that should fall under the namespace Mautic\Auth\ but it simply tells me it cannot be found.

The actual location of the mautic class is [extension root]/Librariesmautic/api-library/lib/Auth/ApiAuth.php

I require my Libraries/autoload.php in my ext_tables.php file.

Can anyone see what I'm doing wrong?

1

1 Answers

1
votes

the package mautic/api-library brings his own composer.json with the psr-4 autoload section, so you don't need to add it to your composer.json.

If you require a package it will installed in the vendor folder (whatever the root composer.json is targeting it), so you can't be able to know where the package will be located.

Just remove the psr-4 section and let the composer autoloader do its magic.