There are 2 things wrong with your code.
You are using PSR-4 wrong.
They removed the need to embed the namespace in your folders, making a cleaner footprint in your project folder.
PSR-0
vendor/<VendorName>/<ProjectName>/src/<NamespaceVendor>/<NamespaceProject>/File.php
PSR-4 (See that they removed the namespaces folders? Because you already reference that in composer.json
vendor/<VendorName>/<ProjectName>/src/File.php
So in your case it would be:
Vendor/myusername/src/File.php
Your composer.json is invalid
"MyNamespace\\":"myusername/src"
Doesn't include the full path to the directory with your project's code. It should be like this:
"autoload": {
"psr-4": {
"MyNamespace\\": "Vendor/myusername/src"
}
}
but the best way to store your files would be outside the vendor
directory, as that is used by automatically downloaded libraries, instead choose a different "development" directory:
"autoload": {
"psr-4": {
"MyUsername\\MyProject\\": "src/myusername/myproject/src"
}
}
Thanks to Sven in the comments.