title: Composer autoload in Wordpress custom plugin
body: <p>I'm developing a brand new Wordpress plugin and I would like to use Composer to autoload classes.</p>
  
  <p>Here is the <strong>plugin directory heriarchy</strong>:</p>
  
  <p><a href="https://i.stack.imgur.com/QP97Z.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/QP97Z.png" alt="enter image description here"></a></p>
  
  <p>my <strong>composer.json</strong> content:</p>
  
  <pre><code>{
      "autoload": {
          "psr-4": {
              "G4S_ECommerce\\": "src"
          }
      }
  }
  </code></pre>
  
  <p>In the directory where composer.json is, on <strong>cmd</strong>, I execute:</p>
  
  <pre><code>composer install -&gt; this generates the vendor/composer folder and the vendore/autoload.php.
  
  composer composer dumpautoload -o -&gt; outputs "Generated optimized autoload files containing 0 classes"
  </code></pre>
  
  <p>In the main file <strong>G4S_Ecommerce.php</strong> I put the following line:</p>
  
  <pre><code> require __DIR__.'/vendor/autoload.php';
  </code></pre>
  
  <p>In the same file I put </p>
  
  <pre><code>use G4S_Ecommerce\Includes\Ecommerce;
  
  $starter = new Ecommerce();
  </code></pre>
  
  <p>but it leads me to a <strong><em>Fatal error: Uncaught Error: Class 'G4S_Ecommerce\Includes\Ecommerce' not found</em></strong></p>
  
  <p>Why the composer dumpautoload -o returns 0 classes? What am I doing wrong?</p>
  
  <p>Thanks</p>