Composer Autoload and ServiceManager Clarification

I’m trying to add a module to the MVC skeleton application and am running into “controller not mapped” and “class not found” errors. I’ve read various posts and documentation to help me debug this. Some of them talk about ServiceManager configuration and some mention composer autoloading configuration. I don’t think I’ve come across any that mentions both.

Could someone please explain how these two thing relate to one another? Is composer autoloading just one of the wasy to make a ClassLoader available to ServiceManager or do they represent different approaches to implementing the apps?

check for a missing comma in your module.config.php in the controllers section that is a common result if you only have one controller

Thanks for the suggestion. I’m mentioned the issue I’m having in the question just to provide some context. I posted the question specifically because I want to understand the relationship between ServiceManager and composer autoloading.

Hello and welcome to our forums! :smiley:

The laminas-servicemanager is a dependency injection container which creates the requested and configured objects. But the service manager does not load the related classes from their files.
This is where Composer comes into play. Besides the package dependency management the Composer contains an autoloading feature.
For our applications this means nothing more than some configuration and adding a one-liner:

require __DIR__ . '/vendor/autoload.php';

See the quick start tutorial for usage.

In the past the framework contains an own loading features but that is all history because Composer already solves this problem, also for other packages.

If you find the method with name getAutoloaderConfig in a module class, then this is the old method. This is obsolete and is no longer needed!