I'm trying to create a module for my Magento 2 installation because I need to change some behaviours. I followed this guide to build a module which basically (at the moment) just wants to override a method for GroupManagement class in Customer Model. The matter is that when I run the setup:upgrade command everything seems to be ok, but then every request to the site gets an exception. I looked into logs and found that my class is not found (there is a ReflectionException "class does not exist"). What it seems to me is that something is missing telling the autoloader to load my module's namespace. Should I manually update some autoloader.php file? I don't think that's intended as a solution, but what am I missing?
From your comments I gather your module is being developed under
app/code and you are not following
psr-0 conventions for your classes (code is under a custom
src folder inside of your module). This is fine, but still, since composer is not aware of modules installed under
app/code, it won't know about your
As a workaround for that, you could enter your
psr-4 classpaths in the project
composer.json (the one which is found in the project root), and then run
composer dump-autoload to regenerate the
vendor/autoload.php and all its related files. Even if it is not the cleanest solution, it would still work in your case.
But very important to note: your should never manually edit the autoloader files, since they are re-generated every time you install a new module via composer for example. Also, you probably don't want to put your
vendor folder under version control, your edits would be lost then.
There can be multiple reasons but below could be among them...
1. Check the name space of your classes..
2. give the permission of your Magento directory according to the official document.
3. And obviously all the classes should start with uppercase with same file name.
4. Classes should not contain UNDERSCORE(_).
Hope this will help, please let me know if issue still persist...