Search code examples
symfony4autoload

Symfony4 Kernel doesn't find autoloaded classes


I have a separate structure for copied libs:

bundles/lightsaml/lightsaml/src
bundles/lightsaml/sp-bundle/src
bundles/lightsaml/symfony-bridge/src
bundles/mdanter/ecc/src
bundles/robrichards/xmlseclibs/src

And in composer.json:

"autoload": {
    "psr-4": {
        "App\\": "src/",
        "LightSaml\\SymfonyBridgeBundle\\": "bundles/lightsaml/symfony-bridge/src",
        "LightSaml\\SpBundle\\": "bundles/lightsaml/sp-bundle/src",
        "LightSaml\\": "bundles/lightsaml/lightsaml/src",
        "Mdanter\\": "bundles/mdanter/ecc/src",
        "RobRichards\\": "bundles/robrichards/xmlseclibs/src"
    }
},

Also tried this variant of composer.json:

        "LightSaml\\": [
            "bundles/lightsaml/symfony-bridge/src",
            "bundles/lightsaml/lightsaml/src",
            "bundles/lightsaml/sp-bundle/src"
        ],

In config/bundles.php:

LightSaml\SymfonyBridgeBundle\LightSamlSymfonyBridgeBundle::class => ['all' => true],
LightSaml\SpBundle\LightSamlSpBundle::class => ['all' => true],

However, I receive the following error:

***ClassNotFoundException***

Attempted to load class "LightSamlSymfonyBridgeBundle" from namespace "LightSaml\SymfonyBridgeBundle".
Did you forget a "use" statement for "LightSaml\SymfonyBridgeBundle\LightSamlSymfonyBridgeBundle"?

The project is rebuilt cleanly in docker. Caches cleared etc.

What am I doing wrong?


Solution

  • The solution was to use classmaps (turn optimize-autoloader on).