I noticed a discrepancy in your first post outlining your structure as
src/Controllers/api/v1/
vs later as the following
/src/controllers/v2/
Make sure you have the correct path and that the namespace matches the directory path.
your mapping should look like:
"Controller\\V2\\": "/src/controllers/v2",
or
"Controller\\V2\\": "/src/controllers/api/v2",
You’re using custom namespace mappings so check out the following file
/vendor/composer/autoload_psr4.php
You should see something that looks like the following, this is what mine looks like after I run “composer dump-autoload”
return array(
'Whoops\\' => array($vendorDir . '/filp/whoops/src/Whoops'),
'Symfony\\Polyfill\\Mbstring\\' => array($vendorDir . '/symfony/polyfill-mbstring'),
'Symfony\\Component\\VarDumper\\' => array($vendorDir . '/symfony/var-dumper'),
'Slim\\' => array($vendorDir . '/slim/slim/Slim'),
'Service\\' => array($baseDir . '/app/services'),
'Psr\\Log\\' => array($vendorDir . '/psr/log/Psr/Log'),
'Psr\\Http\\Message\\' => array($vendorDir . '/psr/http-message/src'),
'Psr\\Container\\' => array($vendorDir . '/psr/container/src'),
'Monolog\\' => array($vendorDir . '/monolog/monolog/src/Monolog'),
'Model\\Store\\' => array($baseDir . '/app/models/stores'),
'Model\\Repository\\' => array($baseDir . '/app/models/repositories'),
'Model\\Entity\\' => array($baseDir . '/app/models/entities'),
'Middleware\\' => array($baseDir . '/app/middleware'),
'Library\\' => array($baseDir . '/app/libraries'),
'Interop\\Container\\' => array($vendorDir . '/container-interop/container-interop/src/Interop/Container'),
'GuzzleHttp\\Psr7\\' => array($vendorDir . '/guzzlehttp/psr7/src'),
'GuzzleHttp\\Promise\\' => array($vendorDir . '/guzzlehttp/promises/src'),
'GuzzleHttp\\' => array($vendorDir . '/guzzlehttp/guzzle/src'),
'Firebase\\JWT\\' => array($vendorDir . '/firebase/php-jwt/src'),
'FastRoute\\' => array($vendorDir . '/nikic/fast-route/src'),
'Core\\' => array($baseDir . '/app/core'),
'Controller\\Api\\V1\\' => array($baseDir . '/app/controllers/api/v1'),
'Controller\\' => array($baseDir . '/app/controllers'),
);
You should see your mapping. It should look something like
'Controller\\Api\\V2\\' => array($baseDir . '/src/controllers/v2'),
The error you are getting is telling you your mapping is wrong and it cant find your class. Double check your directory path, namespace and make sure you “dump auto-load” after editing your composer.json