php - Why is composer not able to autoload files from my /src folder on production server

one text

On my local environment everything works fine, but on my production server files from my /src folder are not autoloaded by composer. I get the following error:

Warning: require(/home/customer/www/example.com/public_html/wp-content/plugins/example-plugin/vendor/composer/../../src/Commands/Example_Commands.php): Failed to open stream: No such file or directory in /home/customer/www/example.com/public_html/wp-content/plugins/example-plugin/vendor/composer/autoload_real.php on line 55

The file really exists (I checked it multiple times), but it looks like production cannot require a path like:

/home/customer/www/example.com/public_html/wp-content/plugins/example-plugin/vendor/composer/../../src/Commands/Example_Commands.php

But only:

/home/customer/www/example.com/public_html/wp-content/plugins/example-plugin/src/Commands/Example_Commands.php

On my local environment I removed already my /vendor folder and composer.lock file and ran the following commands:

> composer dump-autoload

and

> composer install --no-dev

My project folder looks like this:

resources
src
- Commands
  - Example_Commands.php
- Other_Class.php
- Another_Class.php
vendor
- composer
  - ..other composer files
  - autoload_real.php
- ..other packages
composer.json
composer.lock
plugin-index.php

My composer.json looks like this:

{
  "require": {
    "illuminate/encryption": "^9.33",
    "wp-cli/wp-config-transformer": "^1.3",
    "azurre/php-simple-logger": "^1.1"
  },
  "autoload": {
    "files": [
      "src/User.php",
      "src/Utils.php",
      "src/Config_Checker.php",
      "src/Admin_Notices.php",
      "src/ACF.php",
      "src/Commands/Example_Commands.php",
      "src/Service_Logic.php",
      "src/Cron.php",
      "src/Email.php"
    ]
  }
}

In my plugin-index.php (the first file loaded) I start autoloading like this:

require_once(plugin_dir_path(__FILE__) . 'vendor/autoload.php');

To be clear; I ran the composer commands on my local machine and uploaded the project to the production server.

Source