<p>So based on a bit of research. I don't think you necessarily have to create a settings model, if the settings are purely required from a config file. You could use something like:</p>

<pre><code>$settings = Craft::$app-&gt;config-&gt;getConfigFromFile('configfilename');
$exampleSettings = $settings['exampleSomething'];
</code></pre>

<p><code>$settings</code> would be an array, which you could then access each array key.</p>

CC BY-SA 4.0
2019-04-03T09:03:46.043Z
2019-04-03T09:03:46.043Z
James White
<p>I'm currently working on migrating a Craft 2 project which has a bunch of bespoke custom plugins that provided various bits of additional functionality that's tailored to this project only. I've been reading up on the recommended approach in Craft 3 and have understood that modules are better suited in a lot of cases.</p>

<p>However, I've come across a snag with a previous Craft 2 plugin, that basically existed to provide settings that could be referenced in PHP/Twig. This plugin implemented various settings that were defined at <code>config/mycustompluginhandle.php</code>.</p>

<p>I'd like to have the same again but as a module, but it looks like the settings model isn't the same as a plugin and you have to "roll your own" setup for this.</p>

<p>My question is can is a module provide settings via a <code>config/something.php</code> file and can these settings be referenced in other parts of the application i.e. PHP/Twig or another plugin/module? If so, how can I go about doing achieving it?</p>

<craft3><plugins><modules>
Custom module that can define and have settings referenced (Craft 3)
# Custom module that can define and have settings referenced (Craft 3)

(Asked by: username_0 on 2019-03-29)

I'm currently working on migrating a Craft 2 project which has a bunch of bespoke custom plugins that provided various bits of additional functionality that's tailored to this project only. I've been reading up on the recommended approach in Craft 3 and have understood that modules are better suited in a lot of cases.

However, I've come across a snag with a previous Craft 2 plugin, that basically existed to provide settings that could be referenced in PHP/Twig. This plugin implemented various settings that were defined at `config/mycustompluginhandle.php`.

I'd like to have the same again but as a module, but it looks like the settings model isn't the same as a plugin and you have to "roll your own" setup for this.

My question is can is a module provide settings via a `config/something.php` file and can these settings be referenced in other parts of the application i.e. PHP/Twig or another plugin/module? If so, how can I go about doing achieving it?

**Tags:** craft3, plugins, modules


---

## 1 answers

### Answer by username_0 on 2019-04-03. Score: 2 | Accepted answer

So based on a bit of research. I don't think you necessarily have to create a settings model, if the settings are purely required from a config file. You could use something like:
$settings = Craft::$app->config->getConfigFromFile('configfilename');
$exampleSettings = $settings['exampleSomething'];

$settings would be an array, which you could then access each array key.


---

