Answers.Body: <p>Worked when I added a <code>use</code>-statement to the top of scout.php:</p>
  <pre class="lang-php prettyprint-override"><code>&lt;?php
  use modules\sitemodule\services\SitemoduleService as SitemoduleService;
  </code></pre>
  <p>And then:</p>
  <pre class="lang-php prettyprint-override"><code>'indices'       =&gt; (new SitemoduleService)-&gt;getIndicies()
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-04-20T12:12:46.483Z
Answers.LastActivityDate: 2021-04-21T12:04:17.277Z
Answers.LastEditDate: 2021-04-21T12:04:17.277Z
Answers.UserDisplayName: nitech
Body: <p>I have a custom SiteModule that is used inside scout.php to deliver indexing data to Algolia.
  I have followed <a href="https://craftquest.io/courses/algolia-powered-search-in-craft-cms/22271" rel="nofollow noreferrer">CraftQuest's tutorial</a> on creating a custom SiteModule for handling the indicies.</p>
  <p><strong>The setup works when running locally.</strong> But when I run it on my host (Hyperlane), I get the error:
  <code>Class 'modules\sitemodule\services\SiteModuleService' not found</code></p>
  <p>I reference the SiteModule in scout.php thus:</p>
  <pre class="lang-php prettyprint-override"><code>'indices'       =&gt; (new \modules\sitemodule\services\SiteModuleService)-&gt;getIndicies()
  </code></pre>
  <p>App.php contains:</p>
  <pre class="lang-php prettyprint-override"><code>return [
      '*' =&gt; [
          'modules' =&gt; [
              'site-module' =&gt; [
                  'class' =&gt; \modules\sitemodule\SiteModule::class,
              ],
          ],
          'bootstrap' =&gt; ['site-module'],
      ]
  ];
  </code></pre>
  <ul>
  <li>Composer version (local/prod): 2.0.12</li>
  <li>PHP version local/prod: 7.3.12/7.3.3</li>
  </ul>
  <p>What am I doing wrong?</p>
  
Tags: <modules><composer>
Title: Class '...SiteModuleService' not found when used inside scout.php
ThreadText: # Class '...SiteModuleService' not found when used inside scout.php
  
  (Asked by: username_0 on 2021-04-20)
  
  I have a custom SiteModule that is used inside scout.php to deliver indexing data to Algolia.
  I have followed [CraftQuest's tutorial](https://craftquest.io/courses/algolia-powered-search-in-craft-cms/22271) on creating a custom SiteModule for handling the indicies.
  
  **The setup works when running locally.** But when I run it on my host (Hyperlane), I get the error:
  `Class 'modules\sitemodule\services\SiteModuleService' not found`
  
  I reference the SiteModule in scout.php thus:
  
  ```php
  'indices'       => (new \modules\sitemodule\services\SiteModuleService)->getIndicies()
  
  ```
  
  App.php contains:
  
  ```php
  return [
      '*' => [
          'modules' => [
              'site-module' => [
                  'class' => \modules\sitemodule\SiteModule::class,
              ],
          ],
          'bootstrap' => ['site-module'],
      ]
  ];
  
  ```
  
  * Composer version (local/prod): 2.0.12
  * PHP version local/prod: 7.3.12/7.3.3
  
  What am I doing wrong?
  
  **Tags:** modules, composer
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2021-04-20. Score: 2
  
  Worked when I added a `use`-statement to the top of scout.php:
  
  ```php
  <?php
  use modules\sitemodule\services\SitemoduleService as SitemoduleService;
  
  ```
  
  And then:
  
  ```php
  'indices'       => (new SitemoduleService)->getIndicies()
  
  ```
  
  
  ---
  
  