<p>Craft will only look in the immediate <code>pluginHandle/services</code> folder when auto-loading and registering a plugin's service files.</p>

<p>If you wanted to support services in subfolders (i.e. <code>pluginhandle/services/subfolder1</code>, etc.), you'd have to manually autoload and register those classes yourself from your plugin's <code>init()</code> method.</p>

CC BY-SA 3.0
2017-09-06T17:54:53.607Z
2017-09-06T17:54:53.607Z
Brad Bell
<p>So I'm getting to a point where I have a lot of services in a particular plugin, and I would like to organize my plugin services into sub-folders. I've tried a couple ways but the controllers don't seem to be able to find the appropriate services unless they are in the main services directory. I know I can put controller files in sub-folders of the controllers folder, so I thought the same would be true for services. Does Craft support what I'm trying to do?</p>

<php><craft-features><controller><services>
Craft plugin services in subfolders
# Craft plugin services in subfolders

(Asked by: username_0 on 2017-09-06)

So I'm getting to a point where I have a lot of services in a particular plugin, and I would like to organize my plugin services into sub-folders. I've tried a couple ways but the controllers don't seem to be able to find the appropriate services unless they are in the main services directory. I know I can put controller files in sub-folders of the controllers folder, so I thought the same would be true for services. Does Craft support what I'm trying to do?

**Tags:** php, craft-features, controller, services


---

## 1 answers

### Answer by username_1 on 2017-09-06. Score: 2 | Accepted answer

Craft will only look in the immediate `pluginHandle/services` folder when auto-loading and registering a plugin's service files.

If you wanted to support services in subfolders (i.e. `pluginhandle/services/subfolder1`, etc.), you'd have to manually autoload and register those classes yourself from your plugin's `init()` method.


---

