<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>

CC BY-SA 4.0
2021-04-20T12:12:46.483Z
2021-04-21T12:04:17.277Z
2021-04-21T12:04:17.277Z
nitech
<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>

<modules><composer>
Class '...SiteModuleService' not found when used inside scout.php
# 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 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:
'indices'       => (new \modules\sitemodule\services\SiteModuleService)->getIndicies()

App.php contains:
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:

And then:
'indices'       => (new SitemoduleService)->getIndicies()


---

