Composer finishes installing dependencies, but the application reports Class "App\\Service\\MailSender" not found. The package may be present; the autoload mapping, namespace, directory path and filename case still need to agree. A class that loads on Windows but not on a Linux server often points to a case mismatch.
Compare the namespace with the directory tree
Find the PSR-4 mapping for the namespace prefix in composer.json. Then compare the class's relative path under that source directory with the namespace declaration and class name in the file.
{
"autoload": {
"psr-4": {
"App\\": "src/"
}
}
}
With this mapping, a class declared in namespace App\\Service; belongs at src/Service/MailSender.php. On Linux, MailSender.php and Mailsender.php are not interchangeable. The namespace segments and class declaration must also match the file.
A practical order is to copy the exact namespace from the error, locate its prefix in Composer's mapping, and compare the source path and declaration. If the file exists locally but not in production, check whether it is tracked by Git and whether deployment used the expected commit before rebuilding the autoloader.
Regenerate autoload data without changing dependencies
From the project root, run composer validate to check the configuration, then use composer dump-autoload -o to rebuild an optimized autoloader. Test the class with the PHP version and runtime used by the application. Running composer update as a reflex can change dependency versions; it is unnecessary when the problem is only a stale or incorrect class map.
The PSR-4 specification defines the namespace-to-path convention, and Composer's basic usage guide documents autoload generation. For organizing namespaces across application layers, see multi-layer MVC architecture in PHP.