Answers.Body: <p>It's a bit difficult without seeing all of your code, but I'm going to guess that you also need to make changes in your <code>config/app.php</code> to make the namespace changes you're making.</p>
  
  <p>So two things I'd recommend... first, you can generate your module's framework here: <a href="https://pluginfactory.io/" rel="nofollow noreferrer">https://pluginfactory.io/</a></p>
  
  <p>...and second I wrote up a tutorial on creating a module in the <a href="https://nystudio107.com/blog/enhancing-a-craft-cms-3-website-with-a-custom-module" rel="nofollow noreferrer">Enhancing a Craft CMS 3 Website with a Custom Module</a> article.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-09-10T18:00:36.790Z
Answers.Text: Ah, the problem was when i set the Module ID in 'config/app.php'. I thought the value of the 'class' key was using the path to the class file. But I see it's actually  '{namespace}\{class name}::class'. 
  
  Thanks @andrew.welch for pointing me in the right direction.
Answers.UserDisplayName: MrMagicalBananaful
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-02-21T20:10:42.387Z
Answers.Text: I added it to the config/app.php file, as well as the composer.json and forgot to run composer update
Answers.UserDisplayName: Brad
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-09-10T17:07:49.130Z
Answers.LastActivityDate: 2018-09-10T17:07:49.130Z
Answers.UserDisplayName: andrew.welch
Answers.Body: <p>I ran into this problem myself recently. It turned out to be a autoloader problem. I had forgotten to run composer dump-autoload on my project directory. I generally don't bother editing the composer autoload file manually.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-02-07T17:11:01.737Z
Answers.LastActivityDate: 2019-02-07T17:11:01.737Z
Answers.UserDisplayName: Bill Bushee
Body: <p>First attempt at making a module. So far all I've done is try to change the namespace of the template that was included with my freshly installed craft 3.0.23.1 project. </p>
  
  <p>Was following the official docs (<a href="https://docs.craftcms.com/v3/extend/module-guide.html#set-up-the-basic-file-structure" rel="nofollow noreferrer">https://docs.craftcms.com/v3/extend/module-guide.html#set-up-the-basic-file-structure</a>) and spend a few hours trying to figure this out on various searches here and elsewhere.</p>
  
  <p>So in the file '/modules/Module.php' I changed</p>
  
  <pre><code>namespace modules;
  </code></pre>
  
  <p>to</p>
  
  <pre><code>namespace banana\modules;
  </code></pre>
  
  <p>, then in '/composer.json' changed:</p>
  
  <pre><code>  "autoload": {
      "psr-4": {
        "modules\\": "modules/"
      }
    },
  </code></pre>
  
  <p>to</p>
  
  <pre><code>  "autoload": {
      "psr-4": {
        "banana\\modules\\": "modules/"
      }
    },
  </code></pre>
  
  <p>Then in Terminal, ran the command 'composer dump-autoload -a' in the project folder. Reload the page and I get the error. Other than just doing the setup wizard, i haven't touched any other files in the project.</p>
  
Tags: <modules>
Title: Getting a 'ReflectionException' error, "Class modules\Module does not exist' when I change the namespace of my module in Craft 3
ThreadText: # Getting a 'ReflectionException' error, "Class modules\Module does not exist' when I change the namespace of my module in Craft 3
  
  (Asked by: username_0 on 2018-09-10)
  
  First attempt at making a module. So far all I've done is try to change the namespace of the template that was included with my freshly installed craft 3.0.23.1 project.
  
  Was following the official docs (<https://docs.craftcms.com/v3/extend/module-guide.html#set-up-the-basic-file-structure>) and spend a few hours trying to figure this out on various searches here and elsewhere.
  
  So in the file '/modules/Module.php' I changed
  
  ```
  namespace modules;
  
  ```
  
  to
  
  ```
  namespace banana\modules;
  
  ```
  
  , then in '/composer.json' changed:
  
  ```
    "autoload": {
      "psr-4": {
        "modules\\": "modules/"
      }
    },
  
  ```
  
  to
  
  ```
    "autoload": {
      "psr-4": {
        "banana\\modules\\": "modules/"
      }
    },
  
  ```
  
  Then in Terminal, ran the command 'composer dump-autoload -a' in the project folder. Reload the page and I get the error. Other than just doing the setup wizard, i haven't touched any other files in the project.
  
  **Tags:** modules
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2018-09-10. Score: 2
  
  It's a bit difficult without seeing all of your code, but I'm going to guess that you also need to make changes in your `config/app.php` to make the namespace changes you're making.
  
  So two things I'd recommend... first, you can generate your module's framework here: <https://pluginfactory.io/>
  
  ...and second I wrote up a tutorial on creating a module in the [Enhancing a Craft CMS 3 Website with a Custom Module](https://nystudio107.com/blog/enhancing-a-craft-cms-3-website-with-a-custom-module) article.
  
  > **Comments:**
  > **username_0**: Ah, the problem was when i set the Module ID in 'config/app.php'. I thought the value of the 'class' key was using the path to the class file. But I see it's actually  '{namespace}\{class name}::class'.   Thanks @username_1 for pointing me in the right direction.  
  > **username_2**: I added it to the config/app.php file, as well as the composer.json and forgot to run composer update  
  
  ---
  
  ### Answer by username_3 on 2019-02-07. Score: 1
  
  I ran into this problem myself recently. It turned out to be a autoloader problem. I had forgotten to run composer dump-autoload on my project directory. I generally don't bother editing the composer autoload file manually.
  
  
  ---
  
  