Answers.Body: <p>I came across the same issue. So how i solved it is to modify the modules array like this and now the module is loading:</p>
  
  <pre><code>return [
      'modules' =&gt; [
          'zip-assets-craft-3-module' =&gt; [
              'class' =&gt; \modules\zipassetscraft3module\ZipAssetsCraft3Module::class,
          ],
      ],
      'bootstrap' =&gt; ['zip-assets-craft-3-module'],
  ];
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-12-05T06:45:22.590Z
Answers.LastActivityDate: 2019-12-05T18:55:00.867Z
Answers.LastEditDate: 2019-12-05T18:55:00.867Z
Answers.UserDisplayName: Christopher Dosin
Body: <p>I created a module with the pluginfactory generator. The module is used for generating a zip file with all the files belonging to a project.</p>
  
  <p>In the <code>composer.json</code> file, I added the following:</p>
  
  <pre><code>"autoload": {
      "psr-4": {
        "zipassetscraft3module\\": "modules/zipassetscraft3module"
      }
    },
  </code></pre>
  
  <p>in the <code>config/app.php</code> I added:</p>
  
  <pre><code>'modules' =&gt; [
        'zip-assets-craft-3-module' =&gt; \modules\zipassetscraft3module\ZipAssetsCraft3Module::class,
      ],
  </code></pre>
  
  <p>In the file <code>controllers/DefaultController.php</code> I added a function called <code>actionDownload()</code> as well as a <code>download()</code> function in the file <code>services/ZipAssetsCraft3ModuleService.php</code></p>
  
  <p>On the website I have a form with the following url as action: <code>https://default.com/actions/zip-assets-craft-3-module/default/download</code></p>
  
  <p>When I submit the form, I get an error:</p>
  
  <blockquote>
    <p>Invalid Configuration – yii\base\InvalidConfigException Failed to
    instantiate component or class
    "modules\zipassetscraft3module\ZipAssetsCraft3Module".</p>
    
    <p>Caused by: ReflectionException Class
    modules\zipassetscraft3module\ZipAssetsCraft3Module does not exist</p>
  </blockquote>
  
  <p>I have dumped the composer autoload, but I don't know why it's not working. Any ideas what I need to change to get this working?</p>
  
  <p>This is the file structure of the module: 
  <a href="https://i.sstatic.net/k4tjH.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/k4tjH.png" alt="enter image description here"></a></p>
  
  <p>So the error message says, there is a class missing, in which file is this class looked for?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-05-28T14:05:08.187Z
Comments.Text: Try to remove `\modules` from `\modules\zipassetscraft3module\ZipAssetsCraft3Module::class` in your `config/app.php`
Comments.UserDisplayName: Oli
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-05-29T21:03:11.463Z
Comments.Text: You don't mention bootstrapping your module; that might be what you're missing. You should have a bootstrap array in `config/app.php`, add the module "key" you created above to the bootstrap array: `'bootstrap' => ['zip-assets-craft-3-module'],`...
Comments.UserDisplayName: Jalen Davenport
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-06-03T10:28:47.763Z
Comments.Text: @Oli that doesn't change anything unfortunately
Comments.UserDisplayName: obs
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-06-03T10:32:18.953Z
Comments.Text: @JalenDavenport when I do this, the error message appears immediately and not only when I call the action. I updated my question and added a screenshot with the file structure
Comments.UserDisplayName: obs
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-06-03T13:57:38.850Z
Comments.Text: @obs ah so you're referencing a Class by the name of `ReflectionException` in your `ZipAssetsCraft3Module.php` file that PHP can't find. Any chance you could post the contents of that file or at least the snippet that contains `ReflectionException`?
Comments.UserDisplayName: Jalen Davenport
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-06-04T14:11:54.350Z
Comments.Text: @JalenDavenport the error message says "Class modules\zipassetscraft3module\ZipAssetsCraft3Module does not exist
  in /www/[...]/vendor/yiisoft/yii2/di/Container.php at line 431". I'm afraid this doesn't help much. In the docs, there is a section about the "Module class": https://docs.craftcms.com/v3/extend/module-guide.html#the-module-class. I don't have a file Module.php in my module, do I need one?
Comments.UserDisplayName: obs
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-06-04T14:25:16.690Z
Comments.Text: @obs if you're getting a different error it would be helpful to explain where you're seeing it and what you changed since the original post. Maybe if you could share your whole codebase in a GitHub repo (or something like that) I could take a quick look... Alternatively, you could post something over in the Craft Discord group, as this isn't a question one can easily answer without a lot more info.
Comments.UserDisplayName: Jalen Davenport
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-06-05T12:16:51.680Z
Comments.Text: @JalenDavenport the codebase of the module is from https://pluginfactory.io/. I then call this action via a form submit: `https://[domain]/actions/zip-assets-craft-3-module/default/download`
  For this I have the function `download()` in `services/ZipAssetsCraft3ModuleService.php`
Comments.UserDisplayName: obs
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-07-03T11:50:50.990Z
Comments.Text: I found the right paths in the readme.md file.
Comments.UserDisplayName: obs
Tags: <craft3><modules>
Title: "Failed to instantiate component or class" when calling Craft module
ThreadText: # "Failed to instantiate component or class" when calling Craft module
  
  (Asked by: username_0 on 2019-05-27)
  
  I created a module with the pluginfactory generator. The module is used for generating a zip file with all the files belonging to a project.
  
  In the `composer.json` file, I added the following:
  
  ```
  "autoload": {
      "psr-4": {
        "zipassetscraft3module\\": "modules/zipassetscraft3module"
      }
    },
  
  ```
  
  in the `config/app.php` I added:
  
  ```
  'modules' => [
        'zip-assets-craft-3-module' => \modules\zipassetscraft3module\ZipAssetsCraft3Module::class,
      ],
  
  ```
  
  In the file `controllers/DefaultController.php` I added a function called `actionDownload()` as well as a `download()` function in the file `services/ZipAssetsCraft3ModuleService.php`
  
  On the website I have a form with the following url as action: `https://default.com/actions/zip-assets-craft-3-module/default/download`
  
  When I submit the form, I get an error:
  
  > Invalid Configuration – yii\base\InvalidConfigException Failed to
  > instantiate component or class
  > "modules\zipassetscraft3module\ZipAssetsCraft3Module".
  >
  > Caused by: ReflectionException Class
  > modules\zipassetscraft3module\ZipAssetsCraft3Module does not exist
  
  I have dumped the composer autoload, but I don't know why it's not working. Any ideas what I need to change to get this working?
  
  This is the file structure of the module:
  [![enter image description here](https://i.sstatic.net/k4tjH.png)](https://i.sstatic.net/k4tjH.png)
  
  So the error message says, there is a class missing, in which file is this class looked for?
  
  **Tags:** craft3, modules
  
  > **Comments:**
  > **username_1**: Try to remove `\modules` from `\modules\zipassetscraft3module\ZipAssetsCraft3Module::class` in your `config/app.php`  
  > **username_2**: You don't mention bootstrapping your module; that might be what you're missing. You should have a bootstrap array in `config/app.php`, add the module "key" you created above to the bootstrap array: `'bootstrap' => ['zip-assets-craft-3-module'],`...  
  > **username_0**: @username_1 that doesn't change anything unfortunately  
  > **username_0**: @username_2 when I do this, the error message appears immediately and not only when I call the action. I updated my question and added a screenshot with the file structure  
  > **username_2**: @username_0 ah so you're referencing a Class by the name of `ReflectionException` in your `ZipAssetsCraft3Module.php` file that PHP can't find. Any chance you could post the contents of that file or at least the snippet that contains `ReflectionException`?  
  > **username_0**: @username_2 the error message says "Class modules\zipassetscraft3module\ZipAssetsCraft3Module does not exist in /www/[...]/vendor/yiisoft/yii2/di/Container.php at line 431". I'm afraid this doesn't help much. In the docs, there is a section about the "Module class": https://docs.craftcms.com/v3/extend/module-guide.html#the-module-class. I don't have a file Module.php in my module, do I need one?  
  > **username_2**: @username_0 if you're getting a different error it would be helpful to explain where you're seeing it and what you changed since the original post. Maybe if you could share your whole codebase in a GitHub repo (or something like that) I could take a quick look... Alternatively, you could post something over in the Craft Discord group, as this isn't a question one can easily answer without a lot more info.  
  > **username_0**: @username_2 the codebase of the module is from https://pluginfactory.io/. I then call this action via a form submit: `https://[domain]/actions/zip-assets-craft-3-module/default/download` For this I have the function `download()` in `services/ZipAssetsCraft3ModuleService.php`  
  > **username_0**: I found the right paths in the readme.md file.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_3 on 2019-12-05. Score: 1
  
  I came across the same issue. So how i solved it is to modify the modules array like this and now the module is loading:
  
  ```
  return [
      'modules' => [
          'zip-assets-craft-3-module' => [
              'class' => \modules\zipassetscraft3module\ZipAssetsCraft3Module::class,
          ],
      ],
      'bootstrap' => ['zip-assets-craft-3-module'],
  ];
  
  ```
  
  
  ---
  
  