Interference between WordPress autoloader, Composer autoloader and WordPress actions/functions

I need some clarification about some things that I couldn’t quite figure out by now.

  1. How are custom classes in a wordpress plugin autoloaded by composer?
    1.1 Automatically? Or does the plugin’s composer.json need an "autoload": {"psr-4": {...}}
    1.2 Or is this what the bedrock autoloader does?

My guesses:

  1. They aren’t. Because composer loads first and then wordpress which would result in some undefined wordpress functions.
    1.1 Neither. There needs to be a custom autoloader defined for each plugin. (Which I don’t hope is the case)

If that’s what’s loading the plugins is “just” WordPress then I figure that having a directory structure like with some composer packages isn’t working?:

– src
– composer.json => with autoload {"namespace": "/src"}


Also, assuming that the autoload directive in a composer.json of a wordpress plugin is useable, when using it with files then there could possibly be some undefined wordpress functions again.


So can composer here just be used to install the plugins but not autoload them?

Clarification is really very greatly appreciated. This is all confusing me too hard right now.