PS-4 Autloading custom module I have created a module in modules/Core.php which works great and I can reference it using modules\Core::class. But I want to re-organise my modules. 

I'm not super familiar with PSR-4 loading but I have taken a look at a bunch of modules to try and copy the file structure and composer file.

Here's the file structure I want:

modules
  └── wrux
    └── Core
      ├── README.md
      ├── composer.json
      └── src
        └── Core.php


Here's my modules/wrux/Core/composer.json file:

{
  "name": "wrux/Core",
  "require": {
    "craftcms/cms": "^3.2.0"
  },
  "autoload": {
    "psr-4": {
      "wrux\\Core\\": "src/"
    }
  }
}


After I run composer dump-autoload I was hoping that I can use the wrux\Core namespace but it's not working. My module is only accessible from then modules\wrux\Core\src namespace.

Any ideas here?
I don't think you need to add any composer.json in your module folders
You have to update the project composer.json file only to let the craft know about custom module so that it can load on each boot.
Folder Structure might be like  (inside module folder at the root)




wruxmodule
└── src
    ├── controllers
    │   └── DefaultController.php
    ├── models
    │   └── WruxModuleModel.php
    ├── variables
    │   └── WruxModuleVariable.php
    └── WruxModule.php



Copy below line to config/app.php




 return [
    'modules' =&gt; [
        'wrux-module' =&gt; [
            'class' =&gt; \modules\wruxmodule\WruxModule::class,
        ],
    ],
    'bootstrap' =&gt; ['wrux-module'],
];



Now update the project composer.json file




"autoload": {
    "psr-4": {
      "modules\\wruxmodule\\": "modules/wruxmodule/src/"
    }
},



Finally run




composer dump-autoload ( at project root)